home *** CD-ROM | disk | FTP | other *** search
/ Aminet 49 / Aminet 49 (2002)(GTI - Schatztruhe)[!][Jun 2002].iso / Aminet / util / misc / ReportPlus.lha / ReportPlus / source / rp.c < prev    next >
C/C++ Source or Header  |  2002-04-16  |  101KB  |  2,842 lines

  1. /* $Filename:    ReportPlus/Source/rp.c
  2.  * $VER:         Report+ 5.4
  3.  * $Description: Multipurpose utility
  4.  *
  5.  * © Copyright 1999-2002 James R. Jacobs. Freely distributable.
  6.  *        _
  7.  *       //      -=AMIGA=-
  8.  *      //
  9.  * _   //
  10.  * \\ //
  11.  *  \X/
  12.  
  13. #INCLUDES -------------------------------------------------------------- */
  14.  
  15. /* #include <assert.h> */
  16.  
  17. #include <exec/types.h>
  18. #include <exec/alerts.h>
  19. #include <exec/nodes.h>
  20. #include <exec/memory.h>
  21. #include <exec/execbase.h>
  22. #include <proto/exec.h>
  23. #include <intuition/intuition.h>
  24. #include <clib/intuition_protos.h>
  25. #include <intuition/gadgetclass.h>
  26. #include <libraries/gadtools.h>
  27. #include <clib/gadtools_protos.h>
  28. #include <workbench/workbench.h> /* struct DiskObject */
  29. #include <libraries/asl.h>
  30. #include <proto/asl.h>
  31. #include <dos/dos.h>
  32. #include <dos/dostags.h>
  33. #include <dos/dosextens.h>
  34. #include <proto/dos.h>
  35. #include <diskfont/diskfont.h>
  36. #include <proto/diskfont.h>
  37. #include <graphics/gfx.h>
  38. #include <graphics/displayinfo.h>
  39. #include <graphics/gels.h>
  40. #include <clib/graphics_protos.h>
  41. #include <utility/tagitem.h>
  42. #include <proto/utility.h>
  43. #include <workbench/icon.h>
  44. #include <clib/icon_protos.h>
  45. #include <clib/alib_protos.h>
  46. #include <resources/battmem.h>
  47. #include <resources/battmembitsamiga.h>
  48. #include <resources/battmembitsshared.h>
  49.  
  50. #define ALL_REACTION_CLASSES
  51. #define ALL_REACTION_MACROS
  52. #include <reaction/reaction.h>
  53. #include <clib/alib_protos.h>
  54. #include <clib/texteditor_protos.h>
  55. #include <gadgets/texteditor.h>
  56. #include <pragmas/texteditor_pragmas.h>
  57.  
  58. #define GID_0_LY1   0
  59. #define GID_0_BU1   1 // the function buttons must start from GID_O_BU1,
  60. #define GID_0_BU2   2 // and must all be consecutive.
  61. #define GID_0_BU3   3
  62. #define GID_0_BU4   4
  63. #define GID_0_BU5   5
  64. #define GID_0_BU6   6
  65. #define GID_0_BU7   7
  66. #define GID_0_BU8   8
  67. #define GID_0_BU9   9
  68. #define GID_0_BU10 10
  69. #define GID_0_BU11 11
  70. #define GID_0_BU12 12
  71. #define GID_0_ST1  13
  72. #define GID_0_LY2  14
  73. #define GIDS_0     GID_0_LY2
  74.  
  75. #include <ctype.h>
  76. #include <stdio.h>          /* FILE, printf() */
  77. #include <stdlib.h>         /* EXIT_SUCCESS, EXIT_FAILURE */
  78. #include <string.h>
  79. #include "rp.h"
  80. #include "boards.h"
  81.  
  82. #ifdef __STORM__
  83.    #pragma chip
  84. #endif
  85.  
  86. MODULE struct Image*  image[FUNCTIONS + 1];
  87. MODULE struct BitMap* bitmap[FUNCTIONS + 1];
  88. MODULE STRPTR         imagename[FUNCTIONS + 1] =
  89. {   "PROGDIR:images/f1.ilbm",
  90.     "PROGDIR:images/f2.ilbm",
  91.     "PROGDIR:images/f3.ilbm",
  92.     "PROGDIR:images/f4.ilbm",
  93.     "PROGDIR:images/f5.ilbm",
  94.     "PROGDIR:images/f6.ilbm",
  95.     "PROGDIR:images/f7.ilbm",
  96.     "PROGDIR:images/f8.ilbm",
  97.     "PROGDIR:images/f9.ilbm",
  98.     "PROGDIR:images/f10.ilbm",
  99.     "PROGDIR:images/f11.ilbm",
  100.     "PROGDIR:images/f12.ilbm",
  101.     "PROGDIR:images/amigan.ilbm"
  102. };
  103. MODULE STRPTR FunctionDesc[FUNCTIONS + 2] =
  104. {   // Edit
  105.     "Bug report",         // 1
  106.     "Aminet readme",      // 2
  107.     "Autodoc",            // 4
  108.     "Battery-backed RAM", // 9
  109.     "AGDB review",        // 1
  110.     // View
  111.     "Manufacturer IDs",   // 5
  112.     "IFF FORMs",          // 6
  113.     // Process
  114.     "EOLs/tabs",          // 7
  115.     "Icons",              // 12
  116.     // Report
  117.     "Path size",          // 8
  118.     "System files",       // 10
  119.     // Conduct
  120.     "ACSE test",          // 3
  121.     // (default)
  122.     TITLEBARTEXT
  123. };
  124.  
  125. AGLOBAL struct NewGadget Gadget =
  126. {   0, 0, /* left-x, top-y */
  127.     0, 0, /* width, height */
  128.     0,    /* text */
  129.     NULL, /* font */
  130.     NULL, /* gadget ID */
  131.     NULL, /* flags */
  132.     NULL, /* visual info */
  133.     NULL  /* user data */
  134. };
  135.  
  136. #define MENUENTRIES 13
  137. MODULE struct NewMenu NewMenu[MENUENTRIES] =
  138. {   { NM_TITLE, "Project",       0 , 0,               0, 0},
  139.     {  NM_ITEM, "New",          "N", NM_ITEMDISABLED, 0, 0},
  140.     {  NM_ITEM, "Open...",      "O", NM_ITEMDISABLED, 0, 0},
  141.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  142.     {  NM_ITEM, "Save",         "S", NM_ITEMDISABLED, 0, 0},
  143.     {  NM_ITEM, "Save As...",   "A", NM_ITEMDISABLED, 0, 0},
  144.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  145.     {  NM_ITEM, "Quit Report+", "Q", 0,               0, 0},
  146.     { NM_TITLE, "Help",          0 , 0,               0, 0},
  147.     {  NM_ITEM, "Manual...",    "M", 0,               0, 0},
  148.     {  NM_ITEM, NM_BARLABEL,     0 , 0,               0, 0},
  149.     {  NM_ITEM, "About...",     "?", 0,               0, 0},
  150.     {   NM_END, NULL,            0 , 0,               0, 0}
  151. };
  152.  
  153. MODULE void clearkybd(void);
  154. MODULE void menu(void);
  155. MODULE void parsewb(void);
  156. MODULE void eachwildcard(STRPTR subpattern, ABOOL gui);
  157. MODULE void menu_loop(ULONG gid);
  158. MODULE void AddPathnameToTail(struct List* ListPtr, STRPTR name);
  159. MODULE void clearpathlist(struct List* ListPtr);
  160. MODULE void FreePathnameNodes(struct List* ListPtr);
  161. MODULE void sender_loop(ULONG class, struct Gadget* addr, UWORD code, UWORD qual);
  162.  
  163. int CXBRK(void) { return(0); }    /* Disable SAS/C Ctrl-C handling */
  164. int chkabort(void) { return(0); } /* really */
  165.  
  166. MODULE  struct Window*           AboutWindowPtr  = NULL;
  167. AGLOBAL struct Library          *WindowBase      = NULL,
  168.                                 *LayoutBase      = NULL,
  169.                                 *ButtonBase      = NULL,
  170.                                 *TextEditorBase  = NULL,
  171.                                 *LabelBase       = NULL,
  172.                                 *ListBrowserBase = NULL,
  173.                                 *ChooserBase     = NULL,
  174.                                 *StringBase      = NULL,
  175.                                 *CheckBoxBase    = NULL,
  176.                                 *BoardsBase      = NULL,
  177.                                 *BitMapBase      = NULL,
  178.                                 *FuelGaugeBase   = NULL,
  179.                                 *IntegerBase     = NULL,
  180.                                 *RadioButtonBase = NULL;
  181. AGLOBAL TEXT                    asldir[VLONGFIELD + 1],
  182.                                 aslresult[VLONGFIELD + 1],
  183.                                 IOBuffer[LONGESTFIELD + 1],
  184.                                 globalname[VLONGFIELD + 1],
  185.                                 string[4096 + 1],
  186.                                 weekdaystring[LEN_DATSTRING],
  187.                                 datestring[LEN_DATSTRING],
  188.                                 timestring[LEN_DATSTRING];
  189. AGLOBAL WORD                    xsize;
  190. AGLOBAL SBYTE                   page             = 0,
  191.                                 closer           = 0;
  192. AGLOBAL ULONG                   fillcolour,
  193.                                 increment,
  194.                                 offset,
  195.                                 wbval,
  196.                                 signal;
  197. AGLOBAL ABOOL                   BattBuffer[96],
  198.                                 done             = FALSE,
  199.                                 fillwindows      = FALSE,
  200.                                 ram              = FALSE,
  201.                                 stop             = FALSE;
  202. AGLOBAL struct Library*         IconBase         = NULL;
  203. AGLOBAL struct Menu*            MenuPtr          = NULL;
  204. AGLOBAL struct Screen*          ScreenPtr        = NULL;
  205. AGLOBAL struct Window*          MainWindowPtr    = NULL;
  206. AGLOBAL struct VisualInfo*      VisualInfoPtr    = NULL;
  207. AGLOBAL struct ExAllData*       EADataPtr        = NULL;
  208. AGLOBAL struct Gadget          *BU99_Right       = NULL,
  209.                                *GListPtr         = NULL,
  210.                                *PrevGadPtr       = NULL,
  211.                                *ST1_Company      = NULL,
  212.                                *ST1_Developer    = NULL,
  213.                                *ST1_EMail        = NULL,
  214.                                *ST1_FirstName    = NULL,
  215.                                *ST1_LastName     = NULL,
  216.                                *ST1_Phone        = NULL;
  217. AGLOBAL struct List             EmptyList,
  218.                                 FileList;
  219. AGLOBAL struct SharedStruct shared =
  220. {   0,
  221.     "", ""
  222. };
  223.  
  224. IMPORT struct ExecBase*     SysBase;
  225. // from f1.c
  226. IMPORT struct ReportStruct  report;
  227. // from f2.c
  228. IMPORT struct AminetStruct  aminet;
  229. // from f4.c
  230. IMPORT struct AutodocStruct autodoc;
  231. // from f6.c
  232. IMPORT struct IFFStruct     iff;
  233. // from f7.c
  234. IMPORT struct Gadget*       eol_gadgets[GIDS_7 + 1];
  235. // from f9.c
  236. IMPORT struct Library*      BattMemBase;
  237. // from f11.c
  238. IMPORT struct AGDBStruct    agdb;
  239. // from f12.c
  240. IMPORT struct IconStruct    icon;
  241. IMPORT struct Gadget*       icon_gadgets[GIDS_12 + 1];
  242. IMPORT ABOOL                quit;
  243.  
  244. AGLOBAL       Object*          WinObject[FUNCTIONS + 1]; // note that WindowObject is a reserved macro
  245.  
  246. MODULE TEXT                    pubscreen[256 + 1];
  247. MODULE WORD                    ysize;
  248. MODULE ULONG                   ksval;
  249. MODULE ABOOL                   logo   = TRUE;
  250. MODULE        Object          *AboutWinObject = NULL;
  251. MODULE struct Gadget*          gadgets[GIDS_0 + 1];
  252. MODULE struct RDArgs*          ArgsPtr           = NULL;
  253. MODULE struct TextFont*        FontPtr           = NULL;
  254. MODULE struct WBArg*           WBArg             = NULL;
  255. MODULE struct WBStartup*       WBMsg             = NULL;
  256. MODULE struct ASLBase*         ASLBase         = NULL;
  257. MODULE struct DiskFontBase*    DiskFontBase    = NULL;
  258. MODULE struct Library*         GadToolsBase    = NULL;
  259. MODULE struct IntuitionBase*   IntuitionBase   = NULL;
  260. MODULE struct Library*         VersionBase     = NULL;
  261. MODULE struct TextAttr         Topaz8 =
  262. {    (STRPTR) "topaz.font", 8, FS_NORMAL, FPF_ROMFONT | FPF_DESIGNED
  263. }, /* "topaz.font" is case-sensitive */ WormWars8 =
  264. {    (STRPTR) "WormWars.font", 8, FS_NORMAL, FPF_DISKFONT | FPF_DESIGNED
  265. };
  266. MODULE  struct EasyStruct       EasyStruct =
  267. {   sizeof(struct EasyStruct),
  268.     0,
  269.     "Report+: Error",
  270.     NULL,
  271.     "Quit"
  272. };
  273.  
  274. /* FUNCTIONS -------------------------------------------------------------- */
  275.  
  276. int main(int argc, char** argv)
  277. {   UWORD  i;
  278.     SLONG  args[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  279.     BPTR   OldDir;
  280.     SLONG  number = 0, hostid = 7;
  281. //  BPTR   ConfigHandle = NULL;
  282.  
  283.     /* Start of program.
  284.  
  285.     version embedding into executable */
  286.  
  287.     if (0) /* that is, never */
  288.         Printf("$VER: Report+ 5.4 (16.4.2002)"); /* always d.m.y format */
  289.  
  290.     for (i = 0; i <= FUNCTIONS; i++)
  291.     {   WinObject[i] = NULL;
  292.     }
  293.  
  294.     /* Check for OS3.9+... */
  295.     if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 40L)))
  296.     {   Printf("Report+: Need AmigaOS 3.9+!\n");
  297.         cleanexit(EXIT_FAILURE);
  298.     }
  299.     if ((ksval = SysBase->LibNode.lib_Version) < 40L)
  300.     {   Printf("Report+: Need AmigaOS 3.9+!\n");
  301.         cleanexit(EXIT_FAILURE);
  302.     }
  303.     if (!(VersionBase = (struct Library *) OpenLibrary("version.library", 0L)))
  304.         rq("Can't open version.library!");
  305.     wbval = VersionBase->lib_Version;
  306.     CloseLibrary((struct Library *) VersionBase);
  307.     VersionBase = NULL;
  308.     if (wbval < 45)
  309.     {   Printf("Report+: Need AmigaOS 3.9+!\n");
  310.         cleanexit(EXIT_FAILURE);
  311.     }
  312.  
  313.     if (!(GadToolsBase = (struct Library *) OpenLibrary("gadtools.library", 38L)))
  314.         rq("Can't open GadTools.library V38+!");
  315.     if (!(ASLBase = (struct ASLBase *) OpenLibrary("asl.library", 0L)))
  316.         rq("Can't open ASL.library!");
  317.     if (
  318.         (DiskFontBase = (struct DiskFontBase *) OpenLibrary("diskfont.library", 0L))
  319.     &&  (FontPtr = OpenDiskFont(&WormWars8))
  320.        )
  321.     {   Gadget.ng_TextAttr = (struct TextAttr *) &WormWars8;
  322.     } elif (!(FontPtr = OpenFont(&Topaz8)))
  323.     {   rq("Can't open fonts!");
  324.     } else
  325.     {   Gadget.ng_TextAttr = (struct TextAttr *) &Topaz8;
  326.     }
  327.  
  328.     if (!(ButtonBase      = OpenLibrary("gadgets/button.gadget", 44)))
  329.                        rq("OpenLibrary(\"gadgets/button.gadget\") failed!");
  330.     if (!(CheckBoxBase    = OpenLibrary("gadgets/checkbox.gadget", 44)))
  331.                        rq("OpenLibrary(\"gadgets/checkbox.gadget\") failed!");
  332.     if (!(ChooserBase     = OpenLibrary("gadgets/chooser.gadget", 44)))
  333.                        rq("OpenLibrary(\"gadgets/chooser.gadget\") failed!");
  334.     if (!(LabelBase       = OpenLibrary("images/label.image", 44)))
  335.                        rq("OpenLibrary(\"images/label.image\") failed!");
  336.     if (!(LayoutBase      = OpenLibrary("gadgets/layout.gadget", 44)))
  337.                        rq("OpenLibrary(\"gadgets/layout.gadget\") failed!");
  338.     if (!(ListBrowserBase = OpenLibrary("gadgets/listbrowser.gadget", 0)))
  339.                        rq("OpenLibrary(\"gadgets/listbrowser.gadget\") failed!");
  340.     if (!(StringBase      = OpenLibrary("gadgets/string.gadget", 44)))
  341.                        rq("OpenLibrary(\"gadgets/string.gadget\") failed!");
  342.     if (!(TextEditorBase  = OpenLibrary("gadgets/texteditor.gadget", 0)))
  343.                        rq("OpenLibrary(\"gadgets/texteditor.gadget\") failed!");
  344.     if (!(WindowBase      = OpenLibrary("window.class", 44)))
  345.                        rq("OpenLibrary(\"window.class\") failed!");
  346.     if (!(BitMapBase      = OpenLibrary("images/bitmap.image", 44)))
  347.                        rq("OpenLibrary(\"images/bitmap.image\") failed!");
  348.     if (!(FuelGaugeBase   = OpenLibrary("gadgets/fuelgauge.gadget", 0)))
  349.                        rq("OpenLibrary(\"gadgets/fuelgauge.gadget\") failed!");
  350.     if (!(IntegerBase     = OpenLibrary("gadgets/integer.gadget", 44)))
  351.                        rq("OpenLibrary(\"gadgets/integer.gadget\") failed!");
  352.     if (!(RadioButtonBase = OpenLibrary("gadgets/radiobutton.gadget", 45)))
  353.                        rq("OpenLibrary(\"gadgets/radiobutton.gadget\") (V45) failed!");
  354.     if (!(IconBase        = OpenLibrary("icon.library", 44)))
  355.                        rq("Need icon.library V44+!");
  356.           BoardsBase      = OpenLibrary("boards.library", 0);
  357.  
  358.     pubscreen[0] = 0;
  359.     NewList(&EmptyList);
  360.     NewList(&FileList);
  361.     for (i = 0; i <= FUNCTIONS; i++)
  362.     {   image[i]  =
  363.         bitmap[i] = NULL;
  364.     }
  365.     if (!(EADataPtr = AllocVec(4096, MEMF_CLEAR | MEMF_PUBLIC)))
  366.     {   rq("Out of memory!");
  367.     }
  368.  
  369.     /* This is done for speed. Even though the Version command *might* be
  370.     resident, or *might* fit entirely into the disk buffers, we shouldn't
  371.     count on this being the case. So we copy the Version command into RAM:. */
  372.     if (!SystemTags("Copy C:Version RAM:", SYS_Output, Open("NIL:", MODE_NEWFILE), TAG_DONE))
  373.     {   ram = TRUE;
  374.     }
  375.  
  376.     report_init();    // f1
  377.     aminet_init();    // f2
  378.     autodoc_init();   // f4
  379.     size_init();      // f8
  380.     batt_init();      // f9
  381.     files_init();     // f10
  382.     newagdb(FALSE);   // f11
  383.     /* those must be done before we handle CLI arguments */
  384.  
  385.     if (argc) /* started from CLI */
  386.     {   if (!(ArgsPtr = ReadArgs
  387.         (   "-F=FILL/S,PUBSCREEN/K,-N=NOLOGO/S,FUNCTION/N,-I=ICONTYPE/K,"
  388.             "RESET/S,TIMEOUT/S,LUNS/S,SYNC_XFER/S,SLOW_SYNC/S,TAG_QUEUES/S,HOST_ID/K/N,"
  389.             "FILE/F",
  390.             (LONG *) args,
  391.             NULL
  392.     )))
  393.         {   Printf
  394.             (   "Usage: %s [-f|FILL] [PUBSCREEN <screen>] [-n|NOLOGO] "
  395.                 "[[FUNCTION] <function> "
  396.                 "[-i|ICONTYPE DISK|DRAWER|TOOL|PROJECT|TRASHCAN|DEVICE|KICKSTART|APPICON] "
  397.                 "[RESET [TIMEOUT] [LUNS] [SYNC_XFER] [SLOW_SYNC] [TAG_QUEUES] [HOST_ID <host_id>]] "
  398.                 "[[FILE] <file(s)...>]]\n",
  399.                 argv[0]
  400.             );
  401.             cleanexit(EXIT_FAILURE);
  402.     }
  403.         if (args[0])
  404.         {   fillwindows = TRUE;
  405.         }
  406.         if (args[1])
  407.         {   strcpy(pubscreen, (STRPTR) args[1]);
  408.         }
  409.         if (args[2])
  410.         {   logo = FALSE;
  411.         }
  412.         if (args[3])
  413.         {   number = (SLONG) (*((SLONG *) args[3]));
  414.             if (number >= 1 && number <= FUNCTIONS)
  415.             {   page = closer = (number * 10) + 1;
  416.                 shared.function = number;
  417.             } else
  418.             {   Printf("Report+: <function> must be 1-%ld!\n", FUNCTIONS);
  419.                 cleanexit(EXIT_FAILURE);
  420.         }   }
  421.         if (args[4])
  422.         {   if (number != 12)
  423.             {   Printf("%s: <function> must be 12 for this!\n", argv[0]);
  424.                 cleanexit(EXIT_FAILURE);
  425.             }
  426.             if (!stricmp((STRPTR) args[4], "DISK"))
  427.             {   icon.type = WBDISK;
  428.             } elif (!stricmp((STRPTR) args[4], "DRAWER"))
  429.             {   icon.type = WBDRAWER;
  430.             } elif (!stricmp((STRPTR) args[4], "TOOL"))
  431.             {   icon.type = WBTOOL;
  432.             } elif (!stricmp((STRPTR) args[4], "PROJECT"))
  433.             {   icon.type = WBPROJECT;
  434.             } elif (!stricmp((STRPTR) args[4], "TRASHCAN"))
  435.             {   icon.type = WBGARBAGE;
  436.             } elif (!stricmp((STRPTR) args[4], "DEVICE"))
  437.             {   icon.type = WBDEVICE;
  438.             } elif (!stricmp((STRPTR) args[4], "KICKSTART"))
  439.             {   icon.type = WBKICK;
  440.             } elif (!stricmp((STRPTR) args[4], "APPICON"))
  441.             {   icon.type = WBAPPICON;
  442.             } else
  443.             {   Printf("%s: <icontype> must be DISK, DRAWER, TOOL, PROJECT, TRASHCAN, DEVICE, KICKSTART or APPICON!\n", argv[0]);
  444.                 cleanexit(EXIT_FAILURE);
  445.         }   }
  446.         if (args[5] || args[6] || args[7] || args[8] || args[9] || args[10] || args[11])
  447.         {   if (number != 9)
  448.             {   Printf("%s: <function> must be 9 for this!\n", argv[0]);
  449.                 cleanexit(EXIT_FAILURE);
  450.             }
  451.             if (!args[5])
  452.             {   Printf("%s: You need the RESET switch for this!\n", argv[0]);
  453.                 cleanexit(EXIT_FAILURE);
  454.             }
  455.             for (i = 0; i <= 95; i++)
  456.             {   BattBuffer[i] = FALSE;
  457.             }
  458.             BattBuffer[BATTMEM_AMIGA_AMNESIA_ADDR]          =
  459.             BattBuffer[BATTMEM_SHARED_AMNESIA_ADDR]         = TRUE; // these bits are inverted
  460.             if (args[6])
  461.             {   BattBuffer[BATTMEM_SCSI_TIMEOUT_ADDR]       = TRUE;
  462.             } else BattBuffer[BATTMEM_SCSI_TIMEOUT_ADDR]    = FALSE;
  463.             if (args[7])
  464.             {   BattBuffer[BATTMEM_SCSI_LUNS_ADDR]          = TRUE;
  465.             } else BattBuffer[BATTMEM_SCSI_LUNS_ADDR]       = FALSE;
  466.             if (args[8])
  467.             {   BattBuffer[BATTMEM_SCSI_SYNC_XFER_ADDR]     = TRUE;
  468.             } else BattBuffer[BATTMEM_SCSI_SYNC_XFER_ADDR]  = FALSE;
  469.             if (args[9])
  470.             {   BattBuffer[BATTMEM_SCSI_FAST_SYNC_ADDR]     = TRUE;
  471.             } else BattBuffer[BATTMEM_SCSI_FAST_SYNC_ADDR]  = FALSE;
  472.             if (args[10])
  473.             {   BattBuffer[BATTMEM_SCSI_TAG_QUEUES_ADDR]    = TRUE;
  474.             } else BattBuffer[BATTMEM_SCSI_TAG_QUEUES_ADDR] = FALSE;
  475.             if (args[11]) // these bits are inverted
  476.             {   hostid = (SLONG) (*((SLONG *) args[11]));
  477.                 if (hostid < 0 || hostid > 7)
  478.                 {   Printf("%s: <host_id> must be 0-7!\n", argv[0]);
  479.                     cleanexit(EXIT_FAILURE);
  480.                 }
  481.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR]     = (hostid & 4)? 0 : 1;
  482.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR + 1] = (hostid & 2)? 0 : 1;
  483.                 BattBuffer[BATTMEM_SCSI_HOST_ID_ADDR + 2] = (hostid & 1)? 0 : 1;
  484.             }
  485.             if (!BattMemBase)
  486.             {   if (!(BattMemBase = OpenResource(BATTMEMNAME)))
  487.                 {   rq("Can't open battery RAM resource!");
  488.             }   }
  489.             writebatt(FALSE);
  490.             Printf("Done.\n");
  491.             cleanexit(EXIT_SUCCESS);
  492.         }
  493.         if (args[12])
  494.         {   switch(number)
  495.             {
  496.             case 1:
  497.                 strcpy(report.output, (STRPTR) args[12]);
  498.                 loadreport();
  499.             break;
  500.             case 2:
  501.                 strcpy(aminet.output, (STRPTR) args[12]);
  502.                 loadaminet();
  503.             break;
  504.             case 4:
  505.                 strcpy(autodoc.output, (STRPTR) args[12]);
  506.                 loadautodoc();
  507.             break;
  508.             case 6:
  509.                 strcpy(iff.pathname, (STRPTR) args[12]);
  510.             break;
  511.             case 7:
  512.                 // strcpy(icon.pathname, (STRPTR) args[12]); no need for this
  513.                 strcpy(shared.pathname, (STRPTR) args[12]);
  514.                 convert(FALSE);
  515.                 Printf("All done.\n");
  516.                 cleanexit(EXIT_SUCCESS);
  517.             break;
  518.             case 11:
  519.                 strcpy(  agdb.output, (STRPTR) args[12]);
  520.                 loadagdb();
  521.             break;
  522.             case 12:
  523.                 // strcpy(icon.pathname, (STRPTR) args[12]); // no need for this
  524.                 strcpy(shared.pathname, (STRPTR) args[12]);
  525.                 convert(FALSE);
  526.                 Printf("All done.\n");
  527.                 cleanexit(EXIT_SUCCESS);
  528.             break;
  529.             default:
  530.                 Printf("Report+: <function> must be 1, 2, 6, 7, 11 or 12 for this!\n");
  531.                 cleanexit(EXIT_FAILURE);
  532.             break;
  533.     }   }   }
  534.     else /* started from WB */
  535.     {   WBMsg = (struct WBStartup *) argv;
  536.         WBArg = WBMsg->sm_ArgList; /* head of the arg list */
  537.         for (i = 0; i < WBMsg->sm_NumArgs; i++, WBArg++)
  538.         {   if (WBArg->wa_Lock)
  539.             {   /* something that does not support locks */
  540.                 parsewb();
  541.             } else
  542.             {   /* lock supported; change to the proper directory */
  543.                 OldDir = CurrentDir(WBArg->wa_Lock);
  544.                 parsewb();
  545.                 CurrentDir(OldDir);
  546.             }
  547.             if (i == 1)
  548.             {   ; /* we were started from a project icon, which is
  549.                 currently unsupported */
  550.     }   }   }
  551.  
  552.     strcpy(asldir, "PROGDIR:");
  553.     /* RKM Libraries, p. 59-61: */
  554.     lockscreen();
  555.     if (GetVPModeID(&(ScreenPtr->ViewPort)) == INVALID_ID)
  556.     {   rq("Invalid default public screen mode ID!");
  557.     }
  558.     xsize = ScreenPtr->Width;
  559.     ysize = ScreenPtr->Height;
  560.     unlockscreen();
  561.  
  562. /*  if (ConfigHandle = (BPTR) Open("PROGDIR:ReportPlus.config", MODE_OLDFILE))
  563.     {   if (Read(ConfigHandle, IOBuffer, 24 != -1))
  564.         {   manuf_config(); //                                         20
  565.             iff_config();   //                                       19
  566.             eol_config();   //   0102030405
  567.             size_config();  // 00          06                            2122
  568.             files_config(); //               0708091011                      23
  569.             icon_config();  //                                 161718
  570.             // spare                                   12131415
  571.         }
  572.         Close(ConfigHandle);
  573.         ConfigHandle = NULL;
  574.     } */
  575.  
  576.     while(1)
  577.     {   if (page != 1)
  578.         {   shared.function = page / 10;
  579.         }
  580.         if (page == 1)
  581.             sender();
  582.         elif (page == 11)
  583.             report1();
  584.         elif (page == 12)
  585.             report2();
  586.         elif (page == 21)
  587.             aminet1();
  588.         elif (page == 31)
  589.             acse1();
  590.         elif (page == 32)
  591.             acse2();
  592.         elif (page == 41)
  593.             autodoc1();
  594.         elif (page == 42)
  595.             autodoc2();
  596.         elif (page == 51)
  597.             manuf1();
  598.         elif (page == 61)
  599.             iff1();
  600.         elif (page == 71)
  601.             eol1();
  602.         elif (page == 81)
  603.             size1();
  604.         elif (page == 91)
  605.             batt1();
  606.         elif (page == 101)
  607.             files1();
  608.         elif (page == 111)
  609.             agdb1();
  610.         elif (page == 121)
  611.         {   icon1();
  612.         } else
  613.         {   /* assert(page == 0); */
  614.             menu();
  615. }   }   }
  616.  
  617. MODULE void menu(void)
  618. {   PERSIST ABOOL       first = TRUE;
  619.     AUTO    struct Hook Hook0Struct;
  620.     AUTO    ULONG       i, tag[2];
  621.     AUTO    LONG        bgpen;
  622.  
  623.     if (first)
  624.     {   lockscreen();
  625.         for (i = 0; i < FUNCTIONS; i++)
  626.         {   image[i] = BitMapObject,
  627.                 BITMAP_SourceFile, imagename[i],
  628.                 BITMAP_Width,      35,
  629.                 BITMAP_Height,     32,
  630.                 BITMAP_Screen,     ScreenPtr,
  631.             EndImage;
  632.             if (!image[i])
  633.             {   rq("Can't create ReAction image(s)!");
  634.             }
  635.             GetAttr(BITMAP_BitMap, image[i], (ULONG *) &bitmap[i]);
  636.         }
  637.         unlockscreen();
  638.         first = FALSE;
  639.     }
  640.  
  641.     /* PAGE 0 ************************************************************* */
  642.  
  643.     gadtools(); // needed for menu strip
  644.     InitHook(&Hook0Struct, Hook0Func, NULL);
  645.  
  646.     lockscreen();
  647.  
  648.     bgpen = FindColor
  649.     (   ScreenPtr->ViewPort.ColorMap,
  650.         0x96969696,
  651.         0x96969696,
  652.         0x96969696,
  653.         -1
  654.     );
  655.  
  656.     if (logo)
  657.     {   tag[0] = LAYOUT_AddImage;
  658.         tag[1] = NewObject
  659.         (   BITMAP_GetClass(), NULL,
  660.             // bitmap tags
  661.             BITMAP_SourceFile, "PROGDIR:images/logo.ilbm",
  662.             BITMAP_Masking,    TRUE,
  663.             BITMAP_Screen,     ScreenPtr,
  664.             TAG_DONE
  665.         );
  666.     } else
  667.     {   tag[0] = TAG_IGNORE;
  668.         tag[1] = NULL;
  669.     }
  670.  
  671.     if (!(WinObject[0] = NewObject(WINDOW_GetClass(), NULL,
  672.         // window tags
  673.         WA_PubScreen,             ScreenPtr,
  674.         WA_ScreenTitle,           TITLEBARTEXT,
  675.         WA_Title,                 "Report+: Main Menu",
  676.         WA_Activate,              TRUE,
  677.         WA_DepthGadget,           TRUE,
  678.         WA_DragBar,               TRUE,
  679.         WA_CloseGadget,           TRUE,
  680.         WA_IDCMP,                 IDCMP_RAWKEY | IDCMP_INTUITICKS,
  681.         WINDOW_IDCMPHook,         &Hook0Struct,
  682.         WINDOW_IDCMPHookBits,     IDCMP_RAWKEY | IDCMP_INTUITICKS,
  683.         WINDOW_MenuStrip,         MenuPtr,
  684.         WINDOW_Position,          WPOS_CENTERSCREEN,
  685.         WINDOW_ParentGroup,       gadgets[GID_0_LY1] =
  686.         NewObject
  687.         (   LAYOUT_GetClass(),         NULL,
  688.             // root-layout tags
  689.             LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  690.             LAYOUT_SpaceOuter,         TRUE,
  691.             LAYOUT_DeferLayout,        TRUE,
  692.             LAYOUT_AddChild,
  693.             NewObject
  694.             (   LAYOUT_GetClass(),     NULL,
  695.                 // layout tags
  696.                 LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  697.                 LAYOUT_SpaceOuter,     TRUE,
  698.                 LAYOUT_DeferLayout,    TRUE,
  699.                 LAYOUT_HorizAlignment, LALIGN_CENTER,
  700.                 tag[0],                tag[1],
  701.                 TAG_DONE
  702.             ),
  703.             LAYOUT_AddChild,
  704.             NewObject
  705.             (   LAYOUT_GetClass(), NULL,
  706.                 // layout tags
  707.                 LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  708.                 LAYOUT_SpaceOuter,     TRUE,
  709.                 LAYOUT_DeferLayout,    TRUE,
  710.                 LAYOUT_HorizAlignment, LALIGN_CENTER,
  711.                 LAYOUT_AddImage,
  712.                 NewObject
  713.                 (   LABEL_GetClass(),    NULL,
  714.                     // label tags
  715.                     LABEL_Justification, LJ_CENTRE,
  716.                     LABEL_Text,          "Edit:",
  717.                     TAG_END
  718.                 ),
  719.                 TAG_END
  720.             ),
  721.             CHILD_WeightedHeight,      0,
  722.             LAYOUT_AddChild,
  723.             NewObject
  724.             (   LAYOUT_GetClass(),         NULL,
  725.                 // layout tags
  726.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  727.                 LAYOUT_SpaceOuter,         TRUE,
  728.                 LAYOUT_DeferLayout,        TRUE,
  729.                 LAYOUT_AddChild,           gadgets[GID_0_BU1] =
  730.                 NewObject
  731.                 (   NULL, "button.gadget",
  732.                     // button tags
  733.                     GA_ID,                 GID_0_BU1,
  734.                     GA_Left,               20,
  735.                     GA_Top,                20,
  736.                     GA_Width,              41,
  737.                     GA_Height,             40,
  738.                     GA_RelVerify,          TRUE,
  739.                     GA_Image,
  740.                     NewObject
  741.                     (   BITMAP_GetClass(),   NULL,
  742.                         // bitmap tags
  743.                         BITMAP_BitMap,       bitmap[1 - 1],
  744.                         BITMAP_Width,        35,
  745.                         BITMAP_Height,       32,
  746.                         TAG_DONE
  747.                     ),
  748.                     BUTTON_BackgroundPen,    bgpen,
  749.                     BUTTON_FillPen,          bgpen,
  750.                     TAG_DONE
  751.                 ),
  752.                 LAYOUT_AddChild,           gadgets[GID_0_BU2] =
  753.                 NewObject
  754.                 (   NULL, "button.gadget",
  755.                     // button tags
  756.                     GA_ID,                 GID_0_BU2,
  757.                     GA_Left,               20,
  758.                     GA_Top,                20,
  759.                     GA_Width,              41,
  760.                     GA_Height,             40,
  761.                     GA_RelVerify,          TRUE,
  762.                     GA_Image,
  763.                     NewObject
  764.                     (   BITMAP_GetClass(),   NULL,
  765.                         // bitmap tags
  766.                         BITMAP_BitMap,       bitmap[2 - 1],
  767.                         BITMAP_Width,        35,
  768.                         BITMAP_Height,       32,
  769.                         TAG_DONE
  770.                     ),
  771.                     BUTTON_BackgroundPen,    bgpen,
  772.                     BUTTON_FillPen,          bgpen,
  773.                     TAG_DONE
  774.                 ),
  775.                 LAYOUT_AddChild,           gadgets[GID_0_BU3] =
  776.                 NewObject
  777.                 (   NULL, "button.gadget",
  778.                     // button tags
  779.                     GA_ID,                 GID_0_BU3,
  780.                     GA_Left,               20,
  781.                     GA_Top,                20,
  782.                     GA_Width,              41,
  783.                     GA_Height,             40,
  784.                     GA_RelVerify,          TRUE,
  785.                     GA_Image,              NewObject
  786.                     (   BITMAP_GetClass(),   NULL,
  787.                         // bitmap tags
  788.                         BITMAP_BitMap,       bitmap[4 - 1],
  789.                         BITMAP_Width,        35,
  790.                         BITMAP_Height,       32,
  791.                         TAG_DONE
  792.                     ),
  793.                     BUTTON_BackgroundPen,    bgpen,
  794.                     BUTTON_FillPen,          bgpen,
  795.                     TAG_DONE
  796.                 ),
  797.                 LAYOUT_AddChild,           gadgets[GID_0_BU4] = NewObject
  798.                 (   NULL, "button.gadget",
  799.                     // button tags
  800.                     GA_ID,                 GID_0_BU4,
  801.                     GA_Left,               20,
  802.                     GA_Top,                20,
  803.                     GA_Width,              41,
  804.                     GA_Height,             40,
  805.                     GA_RelVerify,          TRUE,
  806.                     GA_Image,              NewObject
  807.                     (   BITMAP_GetClass(),   NULL,
  808.                         // bitmap tags
  809.                         BITMAP_BitMap,       bitmap[9 - 1],
  810.                         BITMAP_Width,        35,
  811.                         BITMAP_Height,       32,
  812.                         TAG_DONE
  813.                     ),
  814.                     BUTTON_BackgroundPen,    bgpen,
  815.                     BUTTON_FillPen,          bgpen,
  816.                     TAG_DONE
  817.                 ),
  818.                 LAYOUT_AddChild,           gadgets[GID_0_BU5] = (struct Gadget *) NewObject
  819.                 (   NULL, "button.gadget",
  820.                     // button tags
  821.                     GA_ID,                 GID_0_BU5,
  822.                     GA_Left,               20,
  823.                     GA_Top,                20,
  824.                     GA_Width,              41,
  825.                     GA_Height,             40,
  826.                     GA_RelVerify,          TRUE,
  827.                     GA_Image,              NewObject
  828.                     (   BITMAP_GetClass(),   NULL,
  829.                         // bitmap tags
  830.                         BITMAP_BitMap,       bitmap[11 - 1],
  831.                         BITMAP_Width,        35,
  832.                         BITMAP_Height,       32,
  833.                         TAG_DONE
  834.                     ),
  835.                     BUTTON_BackgroundPen,    bgpen,
  836.                     BUTTON_FillPen,          bgpen,
  837.                     TAG_DONE
  838.                 ),
  839.                 TAG_DONE
  840.             ),
  841.             LAYOUT_AddChild,
  842.             NewObject
  843.             (   LAYOUT_GetClass(),         NULL,
  844.                 // layout tags
  845.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  846.                 LAYOUT_SpaceOuter,         TRUE,
  847.                 LAYOUT_DeferLayout,        TRUE,
  848.                 LAYOUT_AddChild,
  849.                 NewObject
  850.                 (   LAYOUT_GetClass(),         NULL,
  851.                     // layout tags
  852.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  853.                     LAYOUT_SpaceOuter,         TRUE,
  854.                     LAYOUT_DeferLayout,        TRUE,
  855.                     LAYOUT_AddChild,
  856.                     NewObject
  857.                     (    LAYOUT_GetClass(),    NULL,
  858.                          // layout tags
  859.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  860.                          LAYOUT_SpaceOuter,    TRUE,
  861.                          LAYOUT_DeferLayout,   TRUE,
  862.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  863.                          LAYOUT_AddImage,
  864.                          NewObject
  865.                          (   LABEL_GetClass(), NULL,
  866.                              // label tags
  867.                              LABEL_Justification, LJ_CENTRE,
  868.                              LABEL_Text,          "View:",
  869.                              TAG_END
  870.                          ),
  871.                          TAG_DONE
  872.                     ),
  873.                     LAYOUT_AddChild,
  874.                     NewObject
  875.                     (   LAYOUT_GetClass(),         NULL,
  876.                         // layout tags
  877.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  878.                         LAYOUT_SpaceOuter,         TRUE,
  879.                         LAYOUT_DeferLayout,        TRUE,
  880.                         LAYOUT_AddChild,           gadgets[GID_0_BU6] =
  881.                         NewObject
  882.                         (   NULL, "button.gadget",
  883.                             // button tags
  884.                             GA_ID,                 GID_0_BU6,
  885.                             GA_Left,               20,
  886.                             GA_Top,                20,
  887.                             GA_Width,              41,
  888.                             GA_Height,             40,
  889.                             GA_RelVerify,          TRUE,
  890.                             GA_Image,              NewObject
  891.                             (   BITMAP_GetClass(),   NULL,
  892.                                 // bitmap tags
  893.                                 BITMAP_BitMap,       bitmap[5 - 1],
  894.                                 BITMAP_Width,        35,
  895.                                 BITMAP_Height,       32,
  896.                                 TAG_DONE
  897.                             ),
  898.                             BUTTON_BackgroundPen,    bgpen,
  899.                             BUTTON_FillPen,          bgpen,
  900.                             TAG_DONE
  901.                         ),
  902.                         LAYOUT_AddChild,           gadgets[GID_0_BU7] =
  903.                         NewObject
  904.                         (   NULL, "button.gadget",
  905.                             // button tags
  906.                             GA_ID,                 GID_0_BU7,
  907.                             GA_Left,               20,
  908.                             GA_Top,                20,
  909.                             GA_Width,              41,
  910.                             GA_Height,             40,
  911.                             GA_RelVerify,          TRUE,
  912.                             GA_Image,              NewObject
  913.                             (   BITMAP_GetClass(),   NULL,
  914.                                 // bitmap tags
  915.                                 BITMAP_BitMap,       bitmap[6 - 1],
  916.                                 BITMAP_Width,        35,
  917.                                 BITMAP_Height,       32,
  918.                                 TAG_DONE
  919.                             ),
  920.                             BUTTON_BackgroundPen,    bgpen,
  921.                             BUTTON_FillPen,          bgpen,
  922.                             TAG_DONE
  923.                         ),
  924.                         TAG_DONE
  925.                     ),
  926.                     TAG_DONE
  927.                 ),
  928.                 LAYOUT_AddChild,
  929.                 NewObject
  930.                 (   LAYOUT_GetClass(),         NULL,
  931.                     // layout tags
  932.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  933.                     LAYOUT_SpaceOuter,         TRUE,
  934.                     LAYOUT_DeferLayout,        TRUE,
  935.                     LAYOUT_AddChild,
  936.                     NewObject
  937.                     (    LAYOUT_GetClass(),    NULL,
  938.                          // layout tags
  939.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  940.                          LAYOUT_SpaceOuter,    TRUE,
  941.                          LAYOUT_DeferLayout,   TRUE,
  942.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  943.                          LAYOUT_AddImage,
  944.                          NewObject
  945.                          (   LABEL_GetClass(), NULL,
  946.                              // label tags
  947.                              LABEL_Justification, LJ_CENTRE,
  948.                              LABEL_Text,          "Process:",
  949.                              TAG_END
  950.                          ),
  951.                          TAG_DONE
  952.                     ),
  953.                     LAYOUT_AddChild,
  954.                     NewObject
  955.                     (   LAYOUT_GetClass(),         NULL,
  956.                         // layout tags
  957.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  958.                         LAYOUT_SpaceOuter,         TRUE,
  959.                         LAYOUT_DeferLayout,        TRUE,
  960.                         LAYOUT_AddChild,           gadgets[GID_0_BU8] =
  961.                         NewObject
  962.                         (   NULL, "button.gadget",
  963.                             // button tags
  964.                             GA_ID,                 GID_0_BU8,
  965.                             GA_Left,               20,
  966.                             GA_Top,                20,
  967.                             GA_Width,              41,
  968.                             GA_Height,             40,
  969.                             GA_RelVerify,          TRUE,
  970.                             GA_Image,              NewObject
  971.                             (   BITMAP_GetClass(),   NULL,
  972.                                 // bitmap tags
  973.                                 BITMAP_BitMap,       bitmap[7 - 1],
  974.                                 BITMAP_Width,        35,
  975.                                 BITMAP_Height,       32,
  976.                                 TAG_DONE
  977.                             ),
  978.                             BUTTON_BackgroundPen,    bgpen,
  979.                             BUTTON_FillPen,          bgpen,
  980.                             TAG_DONE
  981.                         ),
  982.                         LAYOUT_AddChild,           gadgets[GID_0_BU9] =
  983.                         NewObject
  984.                         (   NULL, "button.gadget",
  985.                             // button tags
  986.                             GA_ID,                 GID_0_BU9,
  987.                             GA_Left,               20,
  988.                             GA_Top,                20,
  989.                             GA_Width,              41,
  990.                             GA_Height,             40,
  991.                             GA_RelVerify,          TRUE,
  992.                             GA_Image,              NewObject
  993.                             (   BITMAP_GetClass(),   NULL,
  994.                                 // bitmap tags
  995.                                 BITMAP_BitMap,       bitmap[12 - 1],
  996.                                 BITMAP_Width,        35,
  997.                                 BITMAP_Height,       32,
  998.                                 TAG_DONE
  999.                             ),
  1000.                             BUTTON_BackgroundPen,    bgpen,
  1001.                             BUTTON_FillPen,          bgpen,
  1002.                             TAG_DONE
  1003.                         ),
  1004.                         TAG_DONE
  1005.                     ),
  1006.                     TAG_DONE
  1007.                 ),
  1008.                 TAG_DONE
  1009.             ),
  1010.             LAYOUT_AddChild,
  1011.             NewObject
  1012.             (   LAYOUT_GetClass(),         NULL,
  1013.                 // layout tags
  1014.                 LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1015.                 LAYOUT_SpaceOuter,         TRUE,
  1016.                 LAYOUT_DeferLayout,        TRUE,
  1017.                 LAYOUT_AddChild,
  1018.                 NewObject
  1019.                 (   LAYOUT_GetClass(),         NULL,
  1020.                     // layout tags
  1021.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  1022.                     LAYOUT_SpaceOuter,         TRUE,
  1023.                     LAYOUT_DeferLayout,        TRUE,
  1024.                     LAYOUT_AddChild,
  1025.                     NewObject
  1026.                     (    LAYOUT_GetClass(),       NULL,
  1027.                          // layout tags
  1028.                          LAYOUT_Orientation,      LAYOUT_ORIENT_HORIZ,
  1029.                          LAYOUT_SpaceOuter,       TRUE,
  1030.                          LAYOUT_DeferLayout,      TRUE,
  1031.                          LAYOUT_HorizAlignment,   LALIGN_CENTER,
  1032.                          LAYOUT_AddImage,
  1033.                          NewObject
  1034.                          (   LABEL_GetClass(),    NULL,
  1035.                              // label tags
  1036.                              LABEL_Justification, LJ_CENTRE,
  1037.                              LABEL_Text,          "Report:",
  1038.                              TAG_END
  1039.                          ),
  1040.                          TAG_DONE
  1041.                     ),
  1042.                     LAYOUT_AddChild,
  1043.                     NewObject
  1044.                     (   LAYOUT_GetClass(),         NULL,
  1045.                         // layout tags
  1046.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1047.                         LAYOUT_SpaceOuter,         TRUE,
  1048.                         LAYOUT_DeferLayout,        TRUE,
  1049.                         LAYOUT_AddChild,           gadgets[GID_0_BU10] =
  1050.                         NewObject
  1051.                         (   NULL, "button.gadget",
  1052.                             // button tags
  1053.                             GA_ID,                 GID_0_BU10,
  1054.                             GA_Left,               20,
  1055.                             GA_Top,                20,
  1056.                             GA_Width,              41,
  1057.                             GA_Height,             40,
  1058.                             GA_RelVerify,          TRUE,
  1059.                             GA_Image,              NewObject
  1060.                             (   BITMAP_GetClass(),   NULL,
  1061.                                 // bitmap tags
  1062.                                 BITMAP_BitMap,       bitmap[8 - 1],
  1063.                                 BITMAP_Width,        35,
  1064.                                 BITMAP_Height,       32,
  1065.                                 TAG_DONE
  1066.                             ),
  1067.                             BUTTON_BackgroundPen,    bgpen,
  1068.                             BUTTON_FillPen,          bgpen,
  1069.                             TAG_DONE
  1070.                         ),
  1071.                         LAYOUT_AddChild,           gadgets[GID_0_BU11] =
  1072.                         NewObject
  1073.                         (   NULL,                  "button.gadget",
  1074.                             // button tags
  1075.                             GA_ID,                 GID_0_BU11,
  1076.                             GA_Left,               20,
  1077.                             GA_Top,                20,
  1078.                             GA_Width,              41,
  1079.                             GA_Height,             40,
  1080.                             GA_RelVerify,          TRUE,
  1081.                             GA_Image,              NewObject
  1082.                             (   BITMAP_GetClass(),   NULL,
  1083.                                 // bitmap tags
  1084.                                 BITMAP_BitMap,       bitmap[10 - 1],
  1085.                                 BITMAP_Width,        35,
  1086.                                 BITMAP_Height,       32,
  1087.                                 TAG_DONE
  1088.                             ),
  1089.                             BUTTON_BackgroundPen,    bgpen,
  1090.                             BUTTON_FillPen,          bgpen,
  1091.                             TAG_DONE
  1092.                         ),
  1093.                         TAG_DONE
  1094.                     ),
  1095.                     TAG_DONE
  1096.                 ),
  1097.                 LAYOUT_AddChild,
  1098.                 NewObject
  1099.                 (   LAYOUT_GetClass(),         NULL,
  1100.                     // layout tags
  1101.                     LAYOUT_Orientation,        LAYOUT_ORIENT_VERT,
  1102.                     LAYOUT_SpaceOuter,         TRUE,
  1103.                     LAYOUT_DeferLayout,        TRUE,
  1104.                     LAYOUT_AddChild,
  1105.                     NewObject
  1106.                     (    LAYOUT_GetClass(),    NULL,
  1107.                          // layout tags
  1108.                          LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  1109.                          LAYOUT_SpaceOuter,    TRUE,
  1110.                          LAYOUT_DeferLayout,   TRUE,
  1111.                          LAYOUT_HorizAlignment, LALIGN_CENTER,
  1112.                          LAYOUT_AddImage,
  1113.                          NewObject
  1114.                          (   LABEL_GetClass(), NULL,
  1115.                              // label tags
  1116.                              LABEL_Justification, LJ_CENTRE,
  1117.                              LABEL_Text,          "Conduct:",
  1118.                              TAG_END
  1119.                          ),
  1120.                          TAG_DONE
  1121.                     ),
  1122.                     LAYOUT_AddChild,
  1123.                     NewObject
  1124.                     (   LAYOUT_GetClass(),         NULL,
  1125.                         // layout tags
  1126.                         LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1127.                         LAYOUT_SpaceOuter,         TRUE,
  1128.                         LAYOUT_DeferLayout,        TRUE,
  1129.                         LAYOUT_AddChild,           gadgets[GID_0_BU12] =
  1130.                         NewObject
  1131.                         (   NULL, "button.gadget",
  1132.                             // button tags
  1133.                             GA_ID,                 GID_0_BU12,
  1134.                             GA_Left,               20,
  1135.                             GA_Top,                20,
  1136.                             GA_Width,              41,
  1137.                             GA_Height,             40,
  1138.                             GA_RelVerify,          TRUE,
  1139.                             GA_Image,              NewObject
  1140.                             (   BITMAP_GetClass(),   NULL,
  1141.                                 // bitmap tags
  1142.                                 BITMAP_BitMap,       bitmap[3 - 1],
  1143.                                 BITMAP_Width,        35,
  1144.                                 BITMAP_Height,       32,
  1145.                                 TAG_DONE
  1146.                             ),
  1147.                             BUTTON_BackgroundPen,  bgpen,
  1148.                             BUTTON_FillPen,        bgpen,
  1149.                             TAG_DONE
  1150.                         ),
  1151.                         TAG_DONE
  1152.                     ),
  1153.                     TAG_DONE
  1154.                 ),
  1155.                 TAG_DONE
  1156.             ),
  1157.             LAYOUT_AddChild,          gadgets[GID_0_ST1] =
  1158.             NewObject
  1159.             (   STRING_GetClass(),    NULL,
  1160.                 // string tags
  1161.                 GA_ID,                GID_0_ST1,
  1162.                 GA_ReadOnly,          TRUE,
  1163.                 STRINGA_TextVal,      TITLEBARTEXT,
  1164.                 TAG_END
  1165.             ),
  1166.             CHILD_WeightedHeight,     0,
  1167.             TAG_DONE
  1168.         ),
  1169.         TAG_DONE
  1170.     )))
  1171.     {   rq("Can't create ReAction gadgets!");
  1172.     }
  1173.     unlockscreen();
  1174.     openwindow();
  1175.     loop();
  1176.     closewindow();
  1177. }
  1178.  
  1179. AGLOBAL void cleanexit(SBYTE rc)
  1180. {   // BPTR  ConfigHandle;
  1181.        ULONG i;
  1182.  
  1183.     /* ASL requesters are assumed to be already closed.
  1184.     iffparse.library is never opened or closed. :-O */
  1185.  
  1186.     /* help|about... */
  1187.     if (AboutWindowPtr)
  1188.     {   DisposeObject(AboutWinObject);
  1189.         AboutWindowPtr = NULL;
  1190.     }
  1191.  
  1192.     /* all */
  1193.     unlockscreen(); // in case the screen is locked
  1194.     closewindow();
  1195.  
  1196.     /* Remember that you can't fool around with the list whilst the
  1197.     gadget is still using it. So we close the window before calling
  1198.     these next routines. */
  1199.  
  1200.     report_die();  // f1: deallocates "subsystem" list
  1201.     aminet_exit(); // f2: deallocates "subdirectory" list
  1202.     aminet_die();  // f2: deallocates "main directory" list
  1203.     acse_exit();   // f3: shuts down timer
  1204.     manuf_die();
  1205.     eol_die();
  1206.     size_exit();
  1207.     size_die();    // f8: deallocates "empty" (1-node) columnar list
  1208.     files_exit();  // f10: deallocates "result" list & closes logfile handle
  1209.     files_die();
  1210.     icon_die();
  1211.  
  1212.     if (ram)
  1213.     {   if (!SystemTags("Delete RAM:Version", SYS_Output, Open("NIL:", MODE_NEWFILE), TAG_DONE))
  1214.         {   ram = FALSE;
  1215.     }   }
  1216.     if (EADataPtr)
  1217.     {   FreeVec(EADataPtr);
  1218.         EADataPtr = NULL;
  1219.     }
  1220.     if (FontPtr)
  1221.     {   CloseFont(FontPtr);
  1222.         FontPtr = NULL;
  1223.     }
  1224.     if (ArgsPtr)
  1225.     {   FreeArgs(ArgsPtr);
  1226.         ArgsPtr = NULL;
  1227.     }
  1228.  
  1229.     /* Dispose the images ourselves as button.gadget doesn't
  1230.      * do this for its GA_Image...
  1231.      */
  1232.  
  1233.     for (i = 0; i <= FUNCTIONS; i++)
  1234.     {   if (image[i])
  1235.         {   DisposeObject(image[i]);
  1236.             image[i] = NULL;
  1237.     }   }
  1238.  
  1239. /*  if (rc == EXIT_SUCCESS)
  1240.     {   if (ConfigHandle = (BPTR) Open("PROGDIR:ReportPlus.config", MODE_NEWFILE))
  1241.         {   Write(ConfigHandle, IOBuffer, 24);
  1242.             Close(ConfigHandle);
  1243.             ConfigHandle = NULL;
  1244.     }   } */
  1245.  
  1246.     /* ReAction */
  1247.     if (WindowBase)
  1248.     {   CloseLibrary(WindowBase);
  1249.     }
  1250.     if (TextEditorBase)
  1251.     {   CloseLibrary(TextEditorBase);
  1252.     }
  1253.     if (StringBase)
  1254.     {   CloseLibrary(StringBase);
  1255.     }
  1256.     if (ListBrowserBase)
  1257.     {   CloseLibrary(ListBrowserBase);
  1258.     }
  1259.     if (LayoutBase)
  1260.     {   CloseLibrary(LayoutBase);
  1261.     }
  1262.     if (LabelBase)
  1263.     {   CloseLibrary(LabelBase);
  1264.     }
  1265.     if (IntegerBase)
  1266.     {   CloseLibrary(IntegerBase);
  1267.     }
  1268.     if (FuelGaugeBase)
  1269.     {   CloseLibrary(FuelGaugeBase);
  1270.     }
  1271.     if (ChooserBase)
  1272.     {   CloseLibrary(ChooserBase);
  1273.     }
  1274.     if (CheckBoxBase)
  1275.     {   CloseLibrary(CheckBoxBase);
  1276.     }
  1277.     if (ButtonBase)
  1278.     {   CloseLibrary(ButtonBase);
  1279.     }
  1280.     if (BitMapBase)
  1281.     {   CloseLibrary(BitMapBase);
  1282.     }
  1283.  
  1284.     if (BoardsBase)
  1285.         CloseLibrary((struct Library *) BoardsBase);
  1286.     if (IconBase)
  1287.         CloseLibrary((struct Library *) IconBase);
  1288.     if (DiskFontBase)
  1289.         CloseLibrary((struct Library *) DiskFontBase);
  1290.     if (ASLBase)
  1291.         CloseLibrary((struct Library *) ASLBase);
  1292.     if (GadToolsBase)
  1293.         CloseLibrary((struct Library *) GadToolsBase);
  1294.     if (IntuitionBase)
  1295.     {   OpenWorkBench();
  1296.         CloseLibrary((struct Library *) IntuitionBase);
  1297.     }
  1298.  
  1299.     exit(rc); /* End of program. */
  1300. }
  1301.  
  1302. MODULE void clearkybd(void)
  1303. {   struct IntuiMessage* MsgPtr;
  1304.  
  1305.     while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(MainWindowPtr->UserPort))
  1306.         GT_ReplyIMsg(MsgPtr);
  1307. }
  1308.  
  1309. AGLOBAL void FreeNameNodes(struct List* ListPtr)
  1310. {   /* RKM Libraries, p. 496:
  1311.     
  1312.     "Free the entire list, including the header. The header is not
  1313.     updated as the list is freed. This function demonstrates how to
  1314.     avoid referencing freed memory when deallocating nodes." */
  1315.  
  1316.     struct NameNode *WorkNodePtr, *NextNodePtr;
  1317.     
  1318.     WorkNodePtr = (struct NameNode *) (ListPtr->lh_Head); /* first node */
  1319.     while (NextNodePtr = (struct NameNode *) (WorkNodePtr->nn_Node.ln_Succ))
  1320.     {   FreeMem(WorkNodePtr, sizeof(struct NameNode));
  1321.         WorkNodePtr = NextNodePtr;
  1322. }   }
  1323. MODULE void FreePathnameNodes(struct List* ListPtr)
  1324. {   struct PathnameNode *WorkNodePtr, *NextNodePtr;
  1325.     
  1326.     WorkNodePtr = (struct PathnameNode *) (ListPtr->lh_Head); /* first node */
  1327.     while (NextNodePtr = (struct PathnameNode *) (WorkNodePtr->nn_Node.ln_Succ))
  1328.     {   FreeMem(WorkNodePtr, sizeof(struct PathnameNode));
  1329.         WorkNodePtr = NextNodePtr;
  1330. }   }
  1331.  
  1332. AGLOBAL void gadtools(void)
  1333. {   lockscreen();
  1334.     if (!(Gadget.ng_VisualInfo = VisualInfoPtr = (struct VisualInfo *) GetVisualInfo(ScreenPtr, TAG_DONE)))
  1335.     {   rq("Can't get GadTools visual info!");
  1336.     }
  1337.     unlockscreen();
  1338.  
  1339.     if (!(MenuPtr = (struct Menu *) CreateMenus(NewMenu, TAG_DONE)))
  1340.     {   rq("Can't create menus!");
  1341.     }
  1342.     if (!(LayoutMenus(MenuPtr, VisualInfoPtr, GTMN_NewLookMenus, TRUE, TAG_DONE)))
  1343.     {   rq("Can't lay out menus!");
  1344.     }
  1345.     GListPtr = NULL; /* that needs doing for the CreateContext() call */
  1346.     if (!(PrevGadPtr = (struct Gadget *) CreateContext(&GListPtr)))
  1347.     {   rq("Can't create GadTools context!");
  1348. }   }
  1349.  
  1350. AGLOBAL void verynewwindow(SWORD width, SWORD height, STRPTR title, ULONG idcmp)
  1351. {   // Function to open a GadTools window.
  1352.  
  1353.     gadtools();
  1354.     lockscreen();
  1355.  
  1356.     /* open the window on the public screen */
  1357.     if (!(MainWindowPtr = (struct Window*) OpenWindowTags
  1358.     (   NULL,
  1359.         WA_Left,         (xsize / 2) - (width / 2),
  1360.         WA_Top,          12 + ((ysize - 12) / 2) - (height / 2),
  1361.         WA_Width,        width,
  1362.         WA_Height,       height,
  1363.         WA_IDCMP,        IDCMP_CLOSEWINDOW | IDCMP_MENUPICK | IDCMP_REFRESHWINDOW
  1364.                          | IDCMP_MOUSEBUTTONS | IDCMP_INTUITICKS | IDCMP_VANILLAKEY
  1365.                          | IDCMP_RAWKEY | idcmp,
  1366.         WA_Gadgets,      NULL,
  1367.         WA_PubScreen,    ScreenPtr,
  1368.         WA_Activate,     TRUE,
  1369.         WA_Title,        title,
  1370.         WA_DragBar,      TRUE,
  1371.         WA_DepthGadget,  TRUE,
  1372.         WA_CloseGadget,  TRUE,
  1373.         WA_SmartRefresh, TRUE,
  1374.         WA_NewLookMenus, TRUE,
  1375.         TAG_DONE
  1376.     )))
  1377.     {   rq("Can't open window!");
  1378.     }
  1379.     unlockscreen();
  1380.     signal = 1L << MainWindowPtr->UserPort->mp_SigBit;
  1381.  
  1382.     SetMenuStrip(MainWindowPtr, MenuPtr);
  1383.     SetFont(MainWindowPtr->RPort, FontPtr);
  1384.  
  1385.     if (fillwindows)
  1386.     {   getfillcolour();
  1387.         SetAPen
  1388.         (   MainWindowPtr->RPort,
  1389.             fillcolour
  1390.         );
  1391.         RectFill
  1392.         (   MainWindowPtr->RPort,
  1393.             MainWindowPtr->BorderLeft,
  1394.             MainWindowPtr->BorderTop,
  1395.              width - 1 - MainWindowPtr->BorderRight,
  1396.             height - 1 - MainWindowPtr->BorderBottom
  1397.         );
  1398.     }
  1399.  
  1400.     navigate();
  1401. }
  1402.  
  1403. AGLOBAL void helpabout(void)
  1404. {   PERSIST ABOOL first = TRUE;
  1405.  
  1406.     if (AboutWindowPtr)
  1407.     {   return;
  1408.     }
  1409.  
  1410.     lockscreen();
  1411.  
  1412.     if (first)
  1413.     {   image[12] = BitMapObject,
  1414.             BITMAP_SourceFile, imagename[12],
  1415.             BITMAP_Width,      44,
  1416.             BITMAP_Height,     38,
  1417.             BITMAP_Screen,     ScreenPtr,
  1418.         EndImage;
  1419.         if (!image[12])
  1420.         {   rq("Can't create ReAction image!");
  1421.         }
  1422.         GetAttr(BITMAP_BitMap, image[12], (ULONG *) &bitmap[12]);
  1423.         unlockscreen();
  1424.         first = FALSE;
  1425.     }
  1426.  
  1427.     if (!(AboutWinObject = NewObject(WINDOW_GetClass(), NULL,
  1428.         // window tags
  1429.         WA_PubScreen,             ScreenPtr,
  1430.         WA_ScreenTitle,           TITLEBARTEXT,
  1431.         WA_Title,                 "About Report+",
  1432.         WA_Activate,              TRUE,
  1433.         WA_DepthGadget,           TRUE,
  1434.         WA_DragBar,               TRUE,
  1435.         WA_CloseGadget,           TRUE,
  1436.         WINDOW_Position,          WPOS_CENTERSCREEN,
  1437.         WINDOW_ParentGroup,       gadgets[GID_0_LY2] =
  1438.         NewObject
  1439.         (   LAYOUT_GetClass(),         NULL,
  1440.             // root-layout tags
  1441.             LAYOUT_Orientation,        LAYOUT_ORIENT_HORIZ,
  1442.             LAYOUT_SpaceOuter,         TRUE,
  1443.             LAYOUT_DeferLayout,        TRUE,
  1444.             LAYOUT_AddChild,
  1445.             NewObject
  1446.             (   LAYOUT_GetClass(),     NULL,
  1447.                 // layout tags
  1448.                 LAYOUT_Orientation,    LAYOUT_ORIENT_VERT,
  1449.                 LAYOUT_SpaceOuter,     TRUE,
  1450.                 LAYOUT_DeferLayout,    TRUE,
  1451.                 LAYOUT_VertAlignment,  LALIGN_CENTER,
  1452.                 LAYOUT_AddImage,
  1453.                 NewObject
  1454.                 (   BITMAP_GetClass(),   NULL,
  1455.                     // bitmap tags
  1456.                     BITMAP_BitMap,       bitmap[12],
  1457.                     BITMAP_Width,        44,
  1458.                     BITMAP_Height,       38,
  1459.                     TAG_DONE
  1460.                 ),
  1461.                 TAG_DONE
  1462.             ),
  1463.             LAYOUT_AddChild,
  1464.             NewObject
  1465.             (   LAYOUT_GetClass(), NULL,
  1466.                 // layout tags
  1467.                 LAYOUT_Orientation,    LAYOUT_ORIENT_VERT,
  1468.                 LAYOUT_SpaceOuter,     TRUE,
  1469.                 LAYOUT_DeferLayout,    TRUE,
  1470.                 LAYOUT_AddChild,
  1471.                 NewObject
  1472.                 (   LAYOUT_GetClass(), NULL,
  1473.                     // layout tags
  1474.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1475.                     LAYOUT_SpaceOuter,     FALSE,
  1476.                     LAYOUT_DeferLayout,    TRUE,
  1477.                     LAYOUT_AddImage,
  1478.                     NewObject
  1479.                     (   LABEL_GetClass(),    NULL,
  1480.                         // label tags
  1481.                         LABEL_Justification, LJ_CENTRE,
  1482.                         LABEL_Text,          TITLEBARTEXT,
  1483.                         TAG_END
  1484.                     ),
  1485.                     TAG_END
  1486.                 ),
  1487.                 LAYOUT_AddChild,
  1488.                 NewObject
  1489.                 (   LAYOUT_GetClass(), NULL,
  1490.                     // layout tags
  1491.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1492.                     LAYOUT_SpaceOuter,     FALSE,
  1493.                     LAYOUT_DeferLayout,    TRUE,
  1494.                     LAYOUT_AddImage,
  1495.                     NewObject
  1496.                     (   LABEL_GetClass(),    NULL,
  1497.                         // label tags
  1498.                         LABEL_Justification, LJ_CENTRE,
  1499.                         LABEL_Text,          "Tuesday 16 April 2002",
  1500.                         TAG_END
  1501.                     ),
  1502.                     TAG_END
  1503.                 ),
  1504.                 LAYOUT_AddChild,
  1505.                 NewObject
  1506.                 (   LAYOUT_GetClass(), NULL,
  1507.                     // layout tags
  1508.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1509.                     LAYOUT_SpaceOuter,     FALSE,
  1510.                     LAYOUT_DeferLayout,    TRUE,
  1511.                     LAYOUT_AddImage,
  1512.                     NewObject
  1513.                     (   LABEL_GetClass(),    NULL,
  1514.                         // label tags
  1515.                         LABEL_Justification, LJ_CENTRE,
  1516.                         LABEL_Text,          " ",
  1517.                         TAG_END
  1518.                     ),
  1519.                     TAG_END
  1520.                 ),
  1521.                 LAYOUT_AddChild,
  1522.                 NewObject
  1523.                 (   LAYOUT_GetClass(), NULL,
  1524.                     // layout tags
  1525.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1526.                     LAYOUT_SpaceOuter,     FALSE,
  1527.                     LAYOUT_DeferLayout,    TRUE,
  1528.                     LAYOUT_AddImage,
  1529.                     NewObject
  1530.                     (   LABEL_GetClass(),    NULL,
  1531.                         // label tags
  1532.                         LABEL_Justification, LJ_CENTRE,
  1533.                         LABEL_Text,          "© 2002 Amigan Software",
  1534.                         TAG_END
  1535.                     ),
  1536.                     TAG_END
  1537.                 ),
  1538.                 LAYOUT_AddChild,
  1539.                 NewObject
  1540.                 (   LAYOUT_GetClass(), NULL,
  1541.                     // layout tags
  1542.                     LAYOUT_Orientation,    LAYOUT_ORIENT_HORIZ,
  1543.                     LAYOUT_SpaceOuter,     FALSE,
  1544.                     LAYOUT_DeferLayout,    TRUE,
  1545.                     LAYOUT_AddImage,
  1546.                     NewObject
  1547.                     (   LABEL_GetClass(),    NULL,
  1548.                         // label tags
  1549.                         LABEL_Justification, LJ_CENTRE,
  1550.                         LABEL_Text,          "By James R. Jacobs",
  1551.                         TAG_END
  1552.                     ),
  1553.                     TAG_END
  1554.                 ),
  1555.                 TAG_DONE
  1556.             ),
  1557.             TAG_DONE
  1558.         ),
  1559.         TAG_DONE
  1560.     )))
  1561.     {   rq("Can't create ReAction objects!");
  1562.     }
  1563.     unlockscreen();
  1564.  
  1565.     if (!(AboutWindowPtr = (struct Window *) DoMethod((Object *) AboutWinObject, WM_OPEN, NULL)))
  1566.     {   rq("Can't open ReAction window!");
  1567.     }
  1568.  
  1569.     OffMenu(MainWindowPtr, FULLMENUNUM(MN_HELP, IN_ABOUT, NOSUB));
  1570. }
  1571.  
  1572. AGLOBAL void closewindow(void)
  1573. {   if (MainWindowPtr)
  1574.     {   clearkybd();
  1575.  
  1576.         if
  1577.         (   page != 1
  1578.          && (shared.function == 0
  1579.              || shared.function == 2
  1580.              || shared.function == 4
  1581.              || shared.function == 5
  1582.              || shared.function == 7
  1583.              || shared.function == 8
  1584.              || shared.function == 10
  1585.              || shared.function == 11
  1586.              || shared.function == 12
  1587.         )   )
  1588.         {   /* Disposing of the window object will also close the window if it is
  1589.              * already opened, and it will dispose of the layout object attached to it.
  1590.              */
  1591.             DisposeObject(WinObject[shared.function]);
  1592.             WinObject[shared.function] = NULL;
  1593.             MainWindowPtr = NULL;
  1594.         } else
  1595.         {   ClearMenuStrip(MainWindowPtr);
  1596.             CloseWindow(MainWindowPtr);
  1597.             MainWindowPtr = NULL;
  1598.     }   }
  1599.     if (GListPtr)
  1600.     {   FreeGadgets(GListPtr);
  1601.         GListPtr = NULL;
  1602.     }
  1603.     if (MenuPtr)
  1604.     {   FreeMenus(MenuPtr);
  1605.         MenuPtr = NULL;
  1606.     }
  1607.     if (VisualInfoPtr)
  1608.     {   FreeVisualInfo(VisualInfoPtr);
  1609.         VisualInfoPtr = NULL;
  1610. }   }
  1611.  
  1612. AGLOBAL ABOOL asl(STRPTR pattern)
  1613. {   struct FileRequester* ASLRqPtr;
  1614.     ABOOL                 success;
  1615.  
  1616.     /* asldir is the directory that the ASL requester will start in. */
  1617.  
  1618.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, pattern, ASL_Window, MainWindowPtr, TAG_DONE)))
  1619.         rq("Can't create ASL request!");
  1620.     if
  1621.     (   AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, "Report+ file selector", ASL_FuncFlags, FILF_PATGAD, TAG_DONE)
  1622.      && *(ASLRqPtr->rf_File) != 0
  1623.     )
  1624.     {   strcpy(asldir, ASLRqPtr->rf_Dir);
  1625.         strcpy(aslresult, ASLRqPtr->rf_Dir);
  1626.         if (!AddPart(aslresult, ASLRqPtr->rf_File, VLONGFIELD))
  1627.         {   FreeAslRequest(ASLRqPtr);
  1628.             rq("Can't add filename to pathname!");
  1629.         }
  1630.         success = TRUE;
  1631.     } else
  1632.     {   // either the user chose Cancel, or clicked OK with an empty filename
  1633.         strcpy(aslresult, "");
  1634.         success = FALSE;
  1635.     }
  1636.     // assert(ASLRqPtr);
  1637.     FreeAslRequest(ASLRqPtr);
  1638.     return(success);
  1639. }
  1640.  
  1641. AGLOBAL void loop(void)
  1642. {   AUTO SWORD                oldpage = page;
  1643.     AUTO struct Gadget*       addr;
  1644.     AUTO struct IntuiMessage* MsgPtr;
  1645.     AUTO UWORD                code, qual;
  1646.     AUTO ULONG                class, result;
  1647.     AUTO SWORD                mousex, mousey;
  1648.  
  1649.     closer = page;
  1650.     done = FALSE;
  1651.     while (page == oldpage && !done)
  1652.     {   if (AboutWindowPtr)
  1653.         {   if (aboutloop())
  1654.             {   DisposeObject(AboutWinObject);
  1655.                 AboutWindowPtr = NULL;
  1656.                 OnMenu(MainWindowPtr, FULLMENUNUM(MN_HELP, IN_ABOUT, NOSUB));
  1657.         }   }
  1658.         else
  1659.         {   if ((Wait(signal | SIGBREAKF_CTRL_C)) & SIGBREAKF_CTRL_C)
  1660.             {  done = TRUE;
  1661.                /* should we clear the Ctrl-C signal? */
  1662.         }   }
  1663.         if
  1664.         (   shared.function ==  0
  1665.          || (shared.function == 1 && page == 12)
  1666.          || shared.function ==  2
  1667.          || shared.function ==  4
  1668.          || shared.function ==  5
  1669.          || shared.function ==  7
  1670.          || shared.function ==  8
  1671.          || shared.function == 10
  1672.          || shared.function == 11
  1673.          || shared.function == 12
  1674.         ) // handle ReAction windows
  1675.         {   while ((result = DoMethod(WinObject[shared.function], WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  1676.             {   switch (result & WMHI_CLASSMASK)
  1677.                 {
  1678.                 case WMHI_MENUPICK:
  1679.                     handlemenus(code);
  1680.                 break;
  1681.                 case WMHI_CLOSEWINDOW:
  1682.                     if (page == 0)
  1683.                     {   cleanexit(EXIT_SUCCESS);
  1684.                     } else page = 0;
  1685.                 break;
  1686.                 case WMHI_GADGETUP:
  1687.                     switch(shared.function)
  1688.                     {
  1689.                     case 0:
  1690.                         menu_loop(result & WMHI_GADGETMASK);
  1691.                     break;
  1692.                     case 1:
  1693.                         report_ra_loop(result & WMHI_GADGETMASK);
  1694.                     break;
  1695.                     case 2:
  1696.                         aminet_loop(result & WMHI_GADGETMASK);
  1697.                     break;
  1698.                     case 4:
  1699.                         autodoc_loop(result & WMHI_GADGETMASK);
  1700.                     break;
  1701.                     case 5:
  1702.                         manuf_loop(result & WMHI_GADGETMASK);
  1703.                     break;
  1704.                     case 7:
  1705.                         eol_loop(result & WMHI_GADGETMASK);
  1706.                     break;
  1707.                     case 8:
  1708.                         size_loop(result & WMHI_GADGETMASK);
  1709.                     break;
  1710.                     case 10:
  1711.                         files_loop(result & WMHI_GADGETMASK);
  1712.                     break;
  1713.                     case 11:
  1714.                         agdb_loop(result & WMHI_GADGETMASK);
  1715.                     break;
  1716.                     case 12:
  1717.                         icon_loop(result & WMHI_GADGETMASK);
  1718.                     break;
  1719.                     default:
  1720.                         ; // assert(0);
  1721.                     break;
  1722.                     }
  1723.                 break;
  1724.                 default:
  1725.                 break;
  1726.         }   }   }
  1727.         else // handle GadTools windows
  1728.         {   while (MsgPtr = (struct IntuiMessage *) GT_GetIMsg(MainWindowPtr->UserPort))
  1729.             {   class  = MsgPtr->Class;                       
  1730.                 code   = MsgPtr->Code;
  1731.                 addr   = MsgPtr->IAddress;
  1732.                 qual   = MsgPtr->Qualifier;
  1733.                 mousex = MsgPtr->MouseX;
  1734.                 mousey = MsgPtr->MouseY;
  1735.                 GT_ReplyIMsg(MsgPtr);
  1736.                 if (class == IDCMP_CLOSEWINDOW && page == 31)
  1737.                 {   acse_loop(IDCMP_CLOSEWINDOW, addr, code);
  1738.                 } else
  1739.                 {   switch(class)
  1740.                     {
  1741.                     case IDCMP_MENUPICK:
  1742.                         handlemenus(code);
  1743.                     break;
  1744.                     case IDCMP_CLOSEWINDOW:
  1745.                         if (page == 1)
  1746.                         {   if (shared.function == 1)
  1747.                             {   page = 11;
  1748.                             } else
  1749.                             {   // assert(shared.function == 3);
  1750.                                 page = 32;
  1751.                         }   }
  1752.                         else page = 0;
  1753.                     break;
  1754.                     case IDCMP_REFRESHWINDOW:
  1755.                         GT_BeginRefresh(MainWindowPtr);
  1756.                         GT_EndRefresh(MainWindowPtr, TRUE);
  1757.                     break;
  1758.                     default:
  1759.                         if (class == IDCMP_RAWKEY && code == SCAN_HELP)
  1760.                             helpabout();
  1761.                         elif (class == IDCMP_VANILLAKEY && code == ESCAPE && ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT)))
  1762.                             cleanexit(EXIT_SUCCESS);
  1763.                         elif (page == 1)
  1764.                             sender_loop(class, addr, code, qual);
  1765.                         elif (page == 11)
  1766.                             report_gt_loop(class, addr, code, qual);
  1767.                         elif (page >= 31 && page <= 32)
  1768.                             acse_loop(class, addr, code);
  1769.                         elif (page == 61)
  1770.                             iff_loop(class, addr, code, qual);
  1771.                         elif (page == 91)
  1772.                             batt_loop(class, addr, code, qual, mousex, mousey);
  1773.                     break;
  1774. }   }   }   }   }   }
  1775.  
  1776. AGLOBAL void navigate(void)
  1777. {   gadtools();
  1778.  
  1779.     /* BU99_Right is created first, as all windows use it. Therefore all
  1780.     windows can safely call AddGList(), etc. with the BU99_Right argument.
  1781.     This is the only purpose of its existence. */
  1782.  
  1783.     setgadget(0, 0, 0, 0, "", NULL);
  1784.     BU99_Right = PrevGadPtr = (struct Gadget *) CreateGadget
  1785.     (   GENERIC_KIND,
  1786.         PrevGadPtr,
  1787.         &Gadget,
  1788.         TAG_DONE
  1789.     );
  1790. }
  1791.  
  1792. AGLOBAL void setgadget(WORD leftx, WORD topy, WORD width, WORD height,
  1793. STRPTR text, ULONG flags)
  1794. {   Gadget.ng_LeftEdge   = leftx;
  1795.     Gadget.ng_TopEdge    = topy;
  1796.     Gadget.ng_Width      = width;
  1797.     Gadget.ng_Height     = height;
  1798.     Gadget.ng_GadgetText = text;
  1799.     Gadget.ng_Flags      = flags;
  1800. }
  1801.  
  1802. AGLOBAL ABOOL readin(STRPTR pathname)
  1803. {   BPTR FileHandle;
  1804.  
  1805.     if (!(FileHandle = (BPTR) Open(pathname, MODE_OLDFILE)))
  1806.         return FALSE;
  1807.     if (Read(FileHandle, IOBuffer, LONGESTFIELD) == -1)
  1808.     /* Limitation: the whole file must be < 16K */
  1809.     {   Close(FileHandle);
  1810.         return FALSE;
  1811.     }
  1812.     Close(FileHandle);
  1813.     return TRUE;
  1814. }
  1815.  
  1816. AGLOBAL void writeout(STRPTR pathname)
  1817. {   BPTR FileHandle;
  1818.  
  1819.     if (!(FileHandle = (BPTR) Open(pathname, MODE_NEWFILE)))
  1820.         rq("Can't open file for writing!");
  1821.     if (Write(FileHandle, IOBuffer, strlen(IOBuffer)) == -1)
  1822.     {   Close(FileHandle);
  1823.         rq("Can't write to file!");
  1824.     }
  1825.     Close(FileHandle);
  1826. }
  1827.  
  1828. AGLOBAL void rq(STRPTR text)
  1829. {   EasyStruct.es_TextFormat = text;
  1830.     EasyRequest(MainWindowPtr, &EasyStruct, NULL);
  1831.  
  1832.     cleanexit(EXIT_FAILURE);
  1833. }
  1834.  
  1835. AGLOBAL void readordie(STRPTR pathname)
  1836. {   BPTR FileHandle;
  1837.  
  1838.     if (!(FileHandle = (BPTR) Open(pathname, MODE_OLDFILE)))
  1839.         rq("Can't open file for reading!");
  1840.     if (Read(FileHandle, IOBuffer, LONGESTFIELD) == -1)
  1841.     {   Close(FileHandle);
  1842.         rq("Can't read file!");
  1843.     }
  1844.     if (!Close(FileHandle))
  1845.         rq("Can't close file for reading!");
  1846. }
  1847.  
  1848. MODULE void parsewb(void)
  1849. {   struct DiskObject* DiskObject;
  1850.     STRPTR*            ToolArray;
  1851.     STRPTR             s;
  1852.  
  1853.     if ((*WBArg->wa_Name) && (DiskObject = GetDiskObject(WBArg->wa_Name)))
  1854.     {   ToolArray = (STRPTR *) DiskObject->do_ToolTypes;
  1855.  
  1856.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "FILL"))
  1857.             fillwindows = TRUE;
  1858.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "PUBSCREEN"))
  1859.             strcpy(pubscreen, s);
  1860.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "NOLOGO"))
  1861.             logo = FALSE;
  1862.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "ICONTYPE"))
  1863.         {   if (MatchToolValue(s, "DISK"))
  1864.             {   icon.type = WBDISK - 1;
  1865.             } elif (MatchToolValue(s, "DRAWER"))
  1866.             {   icon.type = WBDRAWER - 1;
  1867.             } elif (MatchToolValue(s, "TOOL"))
  1868.             {   icon.type = WBTOOL - 1;
  1869.             } elif (MatchToolValue(s, "PROJECT"))
  1870.             {   icon.type = WBPROJECT - 1;
  1871.             } elif (MatchToolValue(s, "TRASHCAN"))
  1872.             {   icon.type = WBGARBAGE - 1;
  1873.             } elif (MatchToolValue(s, "DEVICE"))
  1874.             {   icon.type = WBDEVICE - 1;
  1875.             } elif (MatchToolValue(s, "KICKSTART"))
  1876.             {   icon.type = WBKICK - 1;
  1877.             } elif (MatchToolValue(s, "APPICON"))
  1878.             {   icon.type = WBAPPICON - 1;
  1879.         }   }
  1880.         if (s = FindToolType((CONST_STRPTR *) ToolArray, "FUNCTION"))
  1881.         {   if (MatchToolValue(s, "1"))
  1882.                 page = 11;
  1883.             elif (MatchToolValue(s, "2"))
  1884.                 page = 21;
  1885.             elif (MatchToolValue(s, "3"))
  1886.                 page = 31;
  1887.             elif (MatchToolValue(s, "4"))
  1888.                 page = 41;
  1889.             elif (MatchToolValue(s, "5"))
  1890.                 page = 51;
  1891.             elif (MatchToolValue(s, "6"))
  1892.                 page = 61;
  1893.             elif (MatchToolValue(s, "7"))
  1894.                 page = 71;
  1895.             elif (MatchToolValue(s, "8"))
  1896.                 page = 81;
  1897.             elif (MatchToolValue(s, "9"))
  1898.                 page = 91;
  1899.             elif (MatchToolValue(s, "10"))
  1900.                 page = 101;
  1901.             elif (MatchToolValue(s, "11"))
  1902.             {   page = 111;
  1903.             } elif (MatchToolValue(s, "12"))
  1904.             {   page = 121;
  1905.         }   }
  1906.         FreeDiskObject(DiskObject);
  1907. }   }
  1908.  
  1909. AGLOBAL void getdate(void)
  1910. {   struct DateTime DateTime;
  1911.  
  1912.     DateTime.dat_Format  = FORMAT_DOS;
  1913.     DateTime.dat_Flags   = NULL;
  1914.     DateTime.dat_StrDay  = weekdaystring;
  1915.     DateTime.dat_StrDate = datestring;
  1916.     DateTime.dat_StrTime = timestring;
  1917.  
  1918.     DateStamp(&(DateTime.dat_Stamp));
  1919.     if (!DateToStr(&DateTime))
  1920.         rq("Can't convert date!");
  1921. }
  1922.  
  1923. AGLOBAL void AddNameToTail(struct List* ListPtr, STRPTR name)
  1924. {   /* RKM Libraries, p. 496:
  1925.     
  1926.     "Allocate a NameNode structure, copy the given name into the
  1927.     structure, then add it [to] the...list." */
  1928.  
  1929.     struct NameNode* NameNodePtr;
  1930.  
  1931.     if (!(NameNodePtr = AllocMem(sizeof(struct NameNode), MEMF_CLEAR)))
  1932.         rq("Out of memory!");
  1933.     strcpy(NameNodePtr->nn_Data, name);
  1934.     NameNodePtr->nn_Node.ln_Name = NameNodePtr->nn_Data;
  1935.     NameNodePtr->nn_Node.ln_Type = NT_USER;
  1936.     NameNodePtr->nn_Node.ln_Pri  = 0;
  1937.     AddTail((struct List *) ListPtr, (struct Node *) NameNodePtr);
  1938. }
  1939. MODULE void AddPathnameToTail(struct List* ListPtr, STRPTR name)
  1940. {   struct PathnameNode* PathnameNodePtr;
  1941.  
  1942.     if (!(PathnameNodePtr = AllocMem(sizeof(struct PathnameNode), MEMF_CLEAR)))
  1943.         rq("Out of memory!");
  1944.     strcpy(PathnameNodePtr->nn_Data, name);
  1945.     PathnameNodePtr->nn_Node.ln_Name = PathnameNodePtr->nn_Data;
  1946.     PathnameNodePtr->nn_Node.ln_Type = NT_USER;
  1947.     PathnameNodePtr->nn_Node.ln_Pri  = 0;
  1948.     AddTail((struct List *) ListPtr, (struct Node *) PathnameNodePtr);
  1949. }
  1950.  
  1951. AGLOBAL void append(STRPTR pathname)
  1952. {   BPTR FileHandle;
  1953.  
  1954.     if (!(FileHandle = (BPTR) Open(pathname, MODE_READWRITE)))
  1955.         rq("Can't open file for appending!");
  1956.     Seek(FileHandle, 0, OFFSET_END);
  1957.     if (Write(FileHandle, IOBuffer, strlen(IOBuffer)) == -1)
  1958.     {   Close(FileHandle);
  1959.         rq("Can't append to file!");
  1960.     }
  1961.     if (!Close(FileHandle))
  1962.         rq("Can't close appended file!");
  1963. }
  1964.  
  1965. AGLOBAL ABOOL aboutloop(void)
  1966. {   struct IntuiMessage* MsgPtr;
  1967.     ABOOL                done = FALSE;
  1968.     UWORD                code, qual;
  1969.     ULONG                class;
  1970.  
  1971.     /* Processes any outstanding messages for the About... window.
  1972.        Returns TRUE if user wants to exit, FALSE otherwise.
  1973.        This should probably be done using ReAction, since it *is* a
  1974.        ReAction window, but this seems to work fine... */
  1975.  
  1976.     while (MsgPtr = (struct IntuiMessage *) GetMsg(AboutWindowPtr->UserPort))
  1977.     {   class = MsgPtr->Class;
  1978.         code  = MsgPtr->Code;
  1979.         qual  = MsgPtr->Qualifier;
  1980.         ReplyMsg((struct Message *) MsgPtr);
  1981.  
  1982.         if (class == CLOSEWINDOW)
  1983.             done = TRUE;
  1984.         elif (class == IDCMP_RAWKEY)
  1985.         {   if ((!(qual & IEQUALIFIER_REPEAT)) && code < KEYUP && (code < FIRSTQUALIFIER || code > LASTQUALIFIER))
  1986.                 done = TRUE;
  1987.     }   }
  1988.     return(done);
  1989. }
  1990.  
  1991. AGLOBAL void drawgadgets(WORD gadgets)
  1992. {   if (!PrevGadPtr)
  1993.         rq("Can't create GadTools gadgets!");
  1994.     AddGList(MainWindowPtr, BU99_Right, (UWORD) ~0, gadgets, NULL);
  1995.     RefreshGList(BU99_Right, MainWindowPtr, NULL, -1);
  1996.     GT_RefreshWindow(MainWindowPtr, NULL);
  1997. }
  1998.  
  1999. AGLOBAL void parse(STRPTR terminator)
  2000. {   ABOOL done = FALSE;
  2001.     ULONG dest = 0; // index in destination string
  2002.  
  2003.     while (!done)
  2004.     {   if (IOBuffer[offset] != CR)
  2005.         {   string[dest] = IOBuffer[offset];
  2006.         }
  2007.         if (!strncmp(&IOBuffer[offset], terminator, strlen(terminator)))
  2008.         {   string[dest] = 0;
  2009.             done = TRUE;
  2010.             offset += strlen(terminator);
  2011.         } elif (offset > strlen(IOBuffer)) // we are past the end of the buffer
  2012.         {   string[0] = 0;
  2013.             done = TRUE;
  2014.         } else
  2015.         {   offset++;
  2016.             if (IOBuffer[offset] != CR)
  2017.             {   dest++;
  2018. }   }   }   }
  2019.  
  2020. AGLOBAL void parsetoend(void)
  2021. {   ABOOL done      = FALSE;
  2022.     ULONG suboffset = 0;
  2023.  
  2024.     while (!done)
  2025.     {   string[suboffset] = IOBuffer[offset];
  2026.         if (offset > strlen(IOBuffer))
  2027.         {   /* EOF */
  2028.             string[suboffset] = 0;
  2029.             done = TRUE;
  2030.         } else
  2031.         {   offset++;
  2032.             suboffset++;
  2033. }   }   }
  2034.  
  2035. AGLOBAL ABOOL saveasl(STRPTR message, STRPTR pattern)
  2036. {   struct FileRequester* ASLRqPtr;
  2037.     TEXT                  tempstring[VLONGFIELD + 1];
  2038.     ABOOL                 success;
  2039.  
  2040.     strcpy(tempstring, "Report+: ");
  2041.     strcat(tempstring, message);
  2042.  
  2043.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, "~(#?.info)", ASL_Window, MainWindowPtr, TAG_DONE)))
  2044.         rq("Can't create ASL request!");
  2045.     if
  2046.     (   AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, tempstring, ASL_FuncFlags, FILF_PATGAD | FILF_SAVE, TAG_DONE)
  2047.      && *(ASLRqPtr->rf_File) != 0
  2048.     )
  2049.     {   strcpy(asldir, ASLRqPtr->rf_Dir);
  2050.         strcpy(aslresult, ASLRqPtr->rf_Dir);
  2051.         if (!AddPart(aslresult, ASLRqPtr->rf_File, VLONGFIELD))
  2052.         {   FreeAslRequest(ASLRqPtr);
  2053.             rq("Can't add filename to pathname!");
  2054.         }
  2055.         success = TRUE;
  2056.     } else
  2057.     {   strcpy(aslresult, "");
  2058.         success = FALSE;
  2059.     }
  2060.     // assert(ASLRqPtr);
  2061.     FreeAslRequest(ASLRqPtr);
  2062.     return(success);
  2063. }
  2064.  
  2065. AGLOBAL void handlemenus(UWORD code)
  2066. {   /* struct MenuItem* ItemPtr; */
  2067.        BPTR             LockPtr;
  2068.  
  2069.     if (code != MENUNULL) /* while (code != MENUNULL) */
  2070.     {   /* ItemPtr = ItemAddress(MenuPtr, code); */
  2071.         switch (MENUNUM(code))
  2072.         {
  2073.         case MN_PROJECT:
  2074.             switch (ITEMNUM(code))
  2075.             {
  2076.             case IN_NEW:
  2077.                 if (shared.function == 1)
  2078.                     newreport(TRUE);
  2079.                 elif (shared.function == 2)
  2080.                     newaminet(TRUE);
  2081.                 elif (shared.function == 4)
  2082.                     newautodoc(TRUE);
  2083.                 elif (page == 111)
  2084.                     newagdb(TRUE);
  2085.             break;
  2086.             case IN_OPEN:
  2087.                 if (shared.function == 1)
  2088.                     openreport();
  2089.                 elif (shared.function == 2)
  2090.                     openaminet();
  2091.                 elif (shared.function == 4)
  2092.                     openautodoc();
  2093.                 elif (page == 91)
  2094.                 {   batt_open();
  2095.                 } elif (page == 111)
  2096.                     openagdb();
  2097.             break;
  2098.             case IN_SAVE:
  2099.                 if (shared.function == 1)
  2100.                     savereport(FALSE);
  2101.                 elif (shared.function == 2)
  2102.                     saveaminet(FALSE);
  2103.                 elif (shared.function == 4)
  2104.                     saveautodoc(FALSE);
  2105.                 elif (page == 91)
  2106.                 {   batt_save(FALSE);
  2107.                 } elif (page == 111)
  2108.                     saveagdb(FALSE);
  2109.             break;
  2110.             case IN_SAVEAS:
  2111.                 if (shared.function == 1)
  2112.                     savereport(TRUE);
  2113.                 elif (shared.function == 2)
  2114.                     saveaminet(TRUE);
  2115.                 elif (shared.function == 4)
  2116.                     saveautodoc(TRUE);
  2117.                 elif (page == 91)
  2118.                 {   batt_save(TRUE);
  2119.                 } elif (page == 111)
  2120.                     saveagdb(TRUE);
  2121.             break;
  2122.             case IN_QUIT:
  2123.                 cleanexit(EXIT_SUCCESS);
  2124.             break;
  2125.             default:
  2126.             break;
  2127.             }
  2128.         break;
  2129.         case MN_HELP:
  2130.             switch (ITEMNUM(code))
  2131.             {
  2132.             case IN_ABOUT:
  2133.                 helpabout();
  2134.             break;
  2135.             case IN_MANUAL:
  2136.                 LockPtr = Lock("CON:", ACCESS_READ);
  2137.                 if (SystemTags
  2138.                 (   "MultiView ReportPlus.guide",
  2139.                     SYS_Input,  (ULONG) LockPtr,
  2140.                     SYS_Output, NULL,
  2141.                     SYS_Asynch, TRUE,
  2142.                     TAG_DONE
  2143.                 ) == -1)
  2144.                 {   DisplayBeep(ScreenPtr);
  2145.                 }
  2146.                 UnLock(LockPtr);
  2147.             break;
  2148.             default:
  2149.             break;
  2150.             }
  2151.         break;
  2152.         default:
  2153.         break;
  2154.         }
  2155.         /* Doing things the above way disables multi-selection,
  2156.         but prevents `endless selection'.
  2157.         code = ItemPtr->NextSelect; */
  2158. }   }
  2159.  
  2160. AGLOBAL void lockscreen(void)
  2161. {   if (pubscreen[0])
  2162.     {   if (!(ScreenPtr = LockPubScreen(pubscreen)))
  2163.         {   rq("Can't lock specified public screen!");
  2164.     }   }
  2165.     else
  2166.     {   if (!(ScreenPtr = LockPubScreen(NULL)))
  2167.         {   rq("Can't lock default public screen!");
  2168. }   }   }
  2169. AGLOBAL void unlockscreen(void)
  2170. {   if (ScreenPtr)
  2171.     {   if (pubscreen[0])
  2172.         {   UnlockPubScreen(pubscreen, ScreenPtr);
  2173.             ScreenPtr = NULL;
  2174.         } else
  2175.         {   UnlockPubScreen(NULL, ScreenPtr);
  2176.             ScreenPtr = NULL;
  2177. }   }   }
  2178.  
  2179. AGLOBAL void getfillcolour(void)
  2180. {   if (fillwindows)
  2181.     {   lockscreen();
  2182.         fillcolour = FindColor
  2183.         (   ScreenPtr->ViewPort.ColorMap,
  2184.             0x99999999, /* red */
  2185.             0x99999999, /* green */
  2186.             0xFFFFFFFF, /* blue */
  2187.            -1
  2188.         );
  2189.         unlockscreen();
  2190.     } else fillcolour = 0;
  2191. }
  2192.  
  2193. MODULE void eachwildcard(STRPTR subpattern, ABOOL gui)
  2194. {   struct AnchorPath* AnchorPathPtr;
  2195.     BPTR               OldDir;
  2196.     BOOL               result;
  2197.     ABOOL              done;
  2198.  
  2199.     shared.thisfile[0] = 0;
  2200.     // AnchorPathPtr must be longword aligned
  2201.     if (!(AnchorPathPtr = AllocMem(sizeof(struct AnchorPath), MEMF_ANY | MEMF_PUBLIC)))
  2202.     {   return;
  2203.     }
  2204.  
  2205.     /* We can't do the processing of the files until we have finished
  2206.     all of the Match...() calls, due to lock problems. So we build a
  2207.     list of the pathnames. */
  2208.  
  2209.     AnchorPathPtr->ap_BreakBits = NULL;
  2210.     AnchorPathPtr->ap_Flags     = NULL;
  2211.     AnchorPathPtr->ap_Strlen    = 0;
  2212.     result = MatchFirst(subpattern, AnchorPathPtr);
  2213.     if (result == 0) // 0 means success
  2214.     {   OldDir = CurrentDir(AnchorPathPtr->ap_Current->an_Lock);
  2215.         if (!NameFromLock(AnchorPathPtr->ap_Current->an_Lock, shared.thisfile, VLONGFIELD))
  2216.         {   MatchEnd(AnchorPathPtr);
  2217.             return;
  2218.         }
  2219.         if (!AddPart(shared.thisfile, AnchorPathPtr->ap_Info.fib_FileName, VLONGFIELD))
  2220.         {   MatchEnd(AnchorPathPtr);
  2221.             return;
  2222.         }
  2223.         CurrentDir(OldDir);
  2224.         AddPathnameToTail(&FileList, shared.thisfile);
  2225.     } elif (result != ERROR_NO_MORE_ENTRIES)
  2226.     {   MatchEnd(AnchorPathPtr);
  2227.         return;
  2228.     }
  2229.  
  2230.     done = FALSE;
  2231.     while (!done)
  2232.     {   result = MatchNext(AnchorPathPtr);
  2233.         if (result == 0)
  2234.         {   OldDir = CurrentDir(AnchorPathPtr->ap_Current->an_Lock);
  2235.             if (!NameFromLock(AnchorPathPtr->ap_Current->an_Lock, shared.thisfile, VLONGFIELD))
  2236.             {   MatchEnd(AnchorPathPtr);
  2237.                 return;
  2238.             }
  2239.             if (!AddPart(shared.thisfile, AnchorPathPtr->ap_Info.fib_FileName, VLONGFIELD))
  2240.             {   MatchEnd(AnchorPathPtr);
  2241.                 return;
  2242.             }
  2243.             CurrentDir(OldDir);
  2244.             AddPathnameToTail(&FileList, shared.thisfile);
  2245.         } elif (result != ERROR_NO_MORE_ENTRIES)
  2246.         {   MatchEnd(AnchorPathPtr);
  2247.             return;
  2248.         } else done = TRUE;
  2249.     }
  2250.     MatchEnd(AnchorPathPtr);
  2251.     FreeMem(AnchorPathPtr, sizeof(struct AnchorPath));
  2252. }
  2253.  
  2254. AGLOBAL void multiasl(STRPTR pattern)
  2255. {   struct FileRequester* ASLRqPtr;
  2256.     ULONG                 i;
  2257.     TEXT                  quotestring[2];
  2258.  
  2259.     quotestring[0] = QUOTE;
  2260.     quotestring[1] = 0;
  2261.  
  2262.     /* It would also be good to correctly
  2263.     handle selection of directories. */
  2264.  
  2265.     if (!(ASLRqPtr = AllocAslRequestTags(ASL_FileRequest, ASL_Pattern, pattern, ASL_Window, MainWindowPtr, TAG_DONE)))
  2266.         rq("Can't create ASL request!");
  2267.     if (AslRequestTags(ASLRqPtr, ASL_Dir, asldir, ASL_Hail, "Report+ file multiselector", ASL_FuncFlags, FILF_PATGAD | FILF_MULTISELECT, TAG_DONE) && *(ASLRqPtr->rf_File) != 0)
  2268.     {   if (ASLRqPtr->rf_NumArgs)
  2269.         {   /* rf_ArgList is an array of WBArg structures. Each entry in
  2270.             this array corresponds to one of the files the user selected
  2271.             (in alphabetical order). The user multiselected; step through
  2272.             the list of selected files. */
  2273.             strcpy(asldir, ASLRqPtr->rf_Dir);
  2274.             strcpy(shared.pathname, quotestring);
  2275.             strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2276.             if (!AddPart(shared.pathname, (ASLRqPtr->rf_ArgList)[0].wa_Name, VLONGFIELD))
  2277.             {   FreeAslRequest(ASLRqPtr);
  2278.                 rq("Can't add filename to pathname!");
  2279.             }
  2280.             strcat(shared.pathname, quotestring);
  2281.             strcat(shared.pathname, " ");
  2282.             for (i = 1; i < ASLRqPtr->rf_NumArgs; i++)
  2283.             {   strcat(shared.pathname, quotestring);
  2284.                 strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2285.                 if (!AddPart(shared.pathname, (ASLRqPtr->rf_ArgList)[i].wa_Name, VLONGFIELD))
  2286.                    rq("Can't add filename to pathname!");
  2287.                 strcat(shared.pathname, quotestring);
  2288.                 if (i < ASLRqPtr->rf_NumArgs - 1)
  2289.                     strcat(shared.pathname, " ");
  2290.         }   }
  2291.         else
  2292.         {   /* The user didn't multiselect; use the normal way to get the
  2293.             filename. */
  2294.  
  2295.             strcpy(asldir, ASLRqPtr->rf_Dir);
  2296.             strcpy(shared.pathname, quotestring);
  2297.             strcat(shared.pathname, ASLRqPtr->rf_Dir);
  2298.             if (!AddPart(shared.pathname, ASLRqPtr->rf_File, VLONGFIELD))
  2299.             {   FreeAslRequest(ASLRqPtr);
  2300.                 rq("Can't add filename to pathname!");
  2301.             }
  2302.             strcat(shared.pathname, quotestring);
  2303.     }   }
  2304.     else
  2305.     {   ; // the user chose Cancel
  2306.     }
  2307.     // assert(ASLRqPtr);
  2308.     FreeAslRequest(ASLRqPtr);
  2309. }
  2310.  
  2311. AGLOBAL void checkabort(ABOOL gui)
  2312. {   ULONG signals, gid, result;
  2313.     UWORD code;
  2314.  
  2315.     /* OK, we've just finished operating on that file. Now before we */
  2316.     /* start on the next one, check whether the user still wants to... */
  2317.     signals = SetSignal(0L, 0L);
  2318.     if (signals & SIGBREAKF_CTRL_C)
  2319.     {   stop = TRUE;
  2320.         SetSignal(0L, SIGBREAKF_CTRL_C); /* clear the Ctrl-C signal */
  2321.         if (gui)
  2322.         {   if (shared.function == 7)
  2323.             {   SetGadgetAttrs
  2324.                 (   eol_gadgets[GID_7_ST2], MainWindowPtr, NULL,
  2325.                     STRINGA_TextVal, "Aborted by user!",
  2326.                 TAG_DONE);
  2327.             } else
  2328.             {   // assert(shared.function == 12);
  2329.                 SetGadgetAttrs
  2330.                 (   icon_gadgets[GID_12_ST2], MainWindowPtr, NULL,
  2331.                     STRINGA_TextVal, "Aborted by user!",
  2332.                 TAG_DONE);
  2333.         }   }
  2334.         else
  2335.         {   Printf("Aborted by user!\n");
  2336.             Flush(Output());
  2337.     }   }
  2338.  
  2339.     while ((result = DoMethod(WinObject[shared.function], WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  2340.     {   switch (result & WMHI_CLASSMASK)
  2341.         {
  2342.         case WMHI_MENUPICK:
  2343.             ; /* handlemenus(code); */
  2344.         break;
  2345.         case WMHI_CLOSEWINDOW:
  2346.             done = quit = TRUE;
  2347.         break;
  2348.         case WMHI_GADGETUP:
  2349.             gid = result & WMHI_GADGETMASK;
  2350.             if
  2351.             (   (shared.function ==  7 && gid == GID_7_BU4)
  2352.              || (shared.function == 12 && gid == GID_12_BU4)
  2353.             )
  2354.             {   stop = TRUE;
  2355.             }
  2356.         break;
  2357.         default:
  2358.         break;
  2359. }   }   }
  2360.  
  2361. AGLOBAL void convert(ABOOL gui)
  2362. {   ULONG        i, j, length;
  2363.     ABOOL        letters, /* are we in letters (TRUE) or whitespace (FALSE)? */
  2364.                  quoted;  /* are we quoted (TRUE) or unquoted (FALSE)? */
  2365.     struct Node* NodePtr;
  2366.  
  2367.     /* At this point we have a list of pathnames, separated by spaces and
  2368.     NULL-terminated. If they came from ASL, they will be quoted, otherwise,
  2369.     they may not. This is the raw input; it can contain anything,
  2370.     including wildcards.
  2371.  
  2372.     shared.pathname: the actual contents of the string gadget.
  2373.     shared.thatfile: each file that we pass to eachwildcard().
  2374.     shared.thisfile: each file that we pass for conversion. */
  2375.  
  2376.     stop = letters = quoted = FALSE;
  2377.     length = strlen(shared.pathname);
  2378.     j = 0;
  2379.  
  2380.     for (i = 0; i < length; i++)
  2381.     {   if (!stop)
  2382.         {   if (shared.pathname[i] == ' ' && letters && !quoted)
  2383.             {   /* if we're unquoted and have a space */
  2384.                 shared.thatfile[j] = 0; /* then NULL-terminate the pathname */
  2385.                 eachwildcard(shared.thatfile, gui);
  2386.                 j = 0;
  2387.                 letters = FALSE;
  2388.             } elif (shared.pathname[i] == QUOTE)
  2389.             {   if (!letters && !quoted)
  2390.                 {   letters = TRUE; /* we're in letters */
  2391.                     quoted = TRUE; /* it's a quote */
  2392.                 } elif (letters && quoted)
  2393.                 {   quoted = FALSE; /* it's an unquote */
  2394.             }   }
  2395.             else
  2396.             {   shared.thatfile[j++] = shared.pathname[i];
  2397.                 letters = TRUE; /* we're in letters */
  2398.     }   }   }
  2399.     /* Now we are at the end. */
  2400.     if (!stop && letters) /* if we're in letters */
  2401.     {   shared.thatfile[j] = 0;
  2402.         /* then it is ended, quoted or not. Although we could */
  2403.         /* report an error condition if there are an odd */
  2404.         /* number of quotes (ie. a missing quote). */
  2405.         eachwildcard(shared.thatfile, gui);
  2406.     }
  2407.     // Walk the list
  2408.     for
  2409.     (   NodePtr = FileList.lh_Head;
  2410.         NodePtr->ln_Succ;
  2411.         NodePtr = NodePtr->ln_Succ
  2412.     )
  2413.     {   if (!stop)
  2414.         {   strcpy(shared.thisfile, NodePtr->ln_Name);
  2415.             if (shared.function == 7)
  2416.             {   eolconvert(gui);
  2417.             } else
  2418.             {   /* assert(shared.function == 12); */
  2419.                 iconconvert(gui);
  2420.     }   }   }
  2421.     clearpathlist(&FileList);
  2422. }
  2423.  
  2424. MODULE void menu_loop(ULONG gid)
  2425. {   switch (gid)
  2426.     {
  2427.     case GID_0_BU1:
  2428.         page = 11;  // bug report
  2429.     break;
  2430.     case GID_0_BU2:
  2431.         page = 21;  // Aminet readme
  2432.     break;
  2433.     case GID_0_BU3:
  2434.         page = 41;  // autodoc
  2435.     break;
  2436.     case GID_0_BU4:
  2437.         page = 91;  // battery RAM
  2438.     break;
  2439.     case GID_0_BU5:
  2440.         page = 111; // AGDB review
  2441.     break;
  2442.     case GID_0_BU6:
  2443.         page = 51;  // ID database
  2444.     break;
  2445.     case GID_0_BU7:
  2446.         page = 61;  // IFF FORMs
  2447.     break;
  2448.     case GID_0_BU8:
  2449.         page = 71;  // EOL/tabs
  2450.     break;
  2451.     case GID_0_BU9:
  2452.         page = 121; // icons
  2453.     break;
  2454.     case GID_0_BU10:
  2455.         page = 81;  // path size
  2456.     break;
  2457.     case GID_0_BU11:
  2458.         page = 101; // system files
  2459.     break;
  2460.     case GID_0_BU12:
  2461.         page = 31;  // ACSE
  2462.     break;
  2463.     default:
  2464.         ; // assert(0);
  2465.     break;
  2466. }   }
  2467.  
  2468. AGLOBAL ULONG Hook0Func(struct Hook *h, VOID *o, VOID *msg)
  2469. {   /* "When the hook is called, the data argument points to the 
  2470.     window object and message argument to the IntuiMessage."
  2471.  
  2472.     These IntuiMessages do not need to be replied to by the appliprog. */
  2473.  
  2474.     AUTO    UWORD code, qual;
  2475.     AUTO    ULONG class, i;
  2476.     AUTO    SWORD mousex, mousey;
  2477.     AUTO    SLONG newover;
  2478.     PERSIST ULONG over = FUNCTIONS;
  2479.  
  2480.     geta4(); // wait till here before doing anything
  2481.  
  2482.     class  = ((struct IntuiMessage *) msg)->Class;
  2483.     code   = ((struct IntuiMessage *) msg)->Code;
  2484.     qual   = ((struct IntuiMessage *) msg)->Qualifier;
  2485.     mousex = ((struct IntuiMessage *) msg)->MouseX;
  2486.     mousey = ((struct IntuiMessage *) msg)->MouseY;
  2487.  
  2488.     switch(class)
  2489.     {
  2490.     case IDCMP_RAWKEY:
  2491.         switch(code)
  2492.         {
  2493.         case SCAN_HELP:
  2494.             helpabout();
  2495.         break;
  2496.         case SCAN_ESCAPE:
  2497.             cleanexit(EXIT_SUCCESS);
  2498.         break;
  2499.         case SCAN_GRAVE:
  2500.             if (qual & IEQUALIFIER_CONTROL)
  2501.             {   decrypt();
  2502.             }
  2503.         break;
  2504.         default:
  2505.         break;
  2506.         }
  2507.     break;
  2508.     case IDCMP_INTUITICKS:
  2509.     {   newover = FUNCTIONS;
  2510.         for (i = 0; i < FUNCTIONS; i++)
  2511.         {   if
  2512.             (   mousex >= gadgets[GID_0_BU1 + i]->LeftEdge
  2513.              && mousex <= gadgets[GID_0_BU1 + i]->LeftEdge + gadgets[GID_0_BU1 + i]->Width  - 1
  2514.              && mousey >= gadgets[GID_0_BU1 + i]->TopEdge
  2515.              && mousey <= gadgets[GID_0_BU1 + i]->TopEdge  + gadgets[GID_0_BU1 + i]->Height - 1
  2516.             )
  2517.             {   newover = i;
  2518.                 break;
  2519.         }   }
  2520.         if (newover != over)
  2521.         {   over = newover;
  2522.             SetGadgetAttrs
  2523.             (   gadgets[GID_0_ST1], MainWindowPtr, NULL,
  2524.                 STRINGA_TextVal, FunctionDesc[over],
  2525.                 TAG_DONE
  2526.             );
  2527.     }   }
  2528.     break;
  2529.     default:
  2530.     break;
  2531.     }
  2532.  
  2533.     return(1);
  2534. }
  2535.  
  2536. /* This function converts register-parameter Hook calling convention into
  2537. standard C conventions. It requires a C compiler that supports
  2538. registerized parameters, such as SAS/C 5.x or greater. */
  2539.  
  2540. AGLOBAL ULONG ASM hookEntry(REG(a0) struct Hook *h, REG(a2) VOID *o, REG(a1) VOID *msg)
  2541. {   // This is the stub function that converts the register-parameters
  2542.     // to stack parameters.
  2543.  
  2544.     return ((*(ULONG (*)(struct Hook *, VOID *, VOID *))(*h->h_SubEntry))(h, o, msg));
  2545. }
  2546.  
  2547. AGLOBAL void InitHook(struct Hook* hook, ULONG (*func)(), void* data)
  2548. {   // Make sure a pointer was passed
  2549.  
  2550.     if (hook)
  2551.     {   // Fill in the Hook fields
  2552.         hook->h_Entry    = (ULONG (*)()) hookEntry;
  2553.         hook->h_SubEntry = func;
  2554.         hook->h_Data     = data;
  2555.     } else
  2556.     {   Printf("Report+: Can't initialize hook (NULL pointer)!");
  2557.         cleanexit(EXIT_FAILURE);
  2558. }   }
  2559.  
  2560. AGLOBAL void clearlist(struct List* ListPtr)
  2561. {   if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2562.     {   FreeNameNodes(ListPtr);
  2563.     }
  2564.     NewList(ListPtr); // prepare for reuse
  2565. }
  2566. MODULE void clearpathlist(struct List* ListPtr)
  2567. {   if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2568.     {   FreePathnameNodes(ListPtr);
  2569.     }
  2570.     NewList(ListPtr); // prepare for reuse
  2571. }
  2572.  
  2573. // Function to free an Exec List of ReAction ListBrowser nodes.
  2574. AGLOBAL void clearreactionlist(struct List* ListPtr)
  2575. {   /* Requirements: listbrowser class must be already open, and list
  2576.     must be detached from gadget*/
  2577.  
  2578.     if (ListPtr->lh_Head->ln_Succ) // if list is non-empty
  2579.     {   FreeListBrowserList(ListPtr);
  2580.     }
  2581.     NewList(ListPtr); // prepare for reuse
  2582. }
  2583.  
  2584. AGLOBAL void openwindow(void)
  2585. {   // Opens a ReAction window.
  2586.  
  2587.     if (!(MainWindowPtr = (struct Window *) DoMethod(WinObject[shared.function], WM_OPEN, NULL)))
  2588.     {   rq("Can't open ReAction window!");        
  2589.     }
  2590.  
  2591.     // Obtain the window wait signal mask.
  2592.     GetAttr(WINDOW_SigMask, WinObject[shared.function], &signal);
  2593. }
  2594.  
  2595. AGLOBAL ABOOL ra_checkbreak(void)
  2596. {   ULONG result;
  2597.     UWORD code;
  2598.  
  2599.     while ((result = DoMethod(WinObject[shared.function], WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
  2600.     {   switch (result & WMHI_CLASSMASK)
  2601.         {
  2602.         case IDCMP_RAWKEY:
  2603.             if (code == SCAN_ESCAPE)
  2604.                 return(1);
  2605.         break;
  2606.         case WMHI_CLOSEWINDOW:
  2607.              return(2);
  2608.         break;
  2609.         case WMHI_GADGETUP:
  2610.              if (shared.function == 8)
  2611.              {   if ((result & (WMHI_GADGETMASK)) == GID_8_BU5) // these parentheses are needed!
  2612.                  {   return(1);
  2613.              }   }
  2614.              else
  2615.              {   // assert(shared.function == 10);
  2616.                  if ((result & (WMHI_GADGETMASK)) == GID_10_BU3) // these parentheses are needed!
  2617.                  {   return(1);
  2618.              }   }
  2619.         break;
  2620.         default:
  2621.         break;
  2622.     }   }
  2623.     return(0);
  2624. }
  2625.  
  2626. AGLOBAL void sender(void)
  2627. {   verynewwindow
  2628.     (   SENDERWIDTH, SENDERHEIGHT,
  2629.         "Report+: Sender Details",
  2630.         BUTTONIDCMP | STRINGIDCMP
  2631.     );
  2632.  
  2633.     if (readin("S:Report.sender"))
  2634.     {   /* # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
  2635.            # Path: <email><LF>
  2636.            # ReferID: <developer><LF> */
  2637.  
  2638.         offset = 0;
  2639.         parse("# Refer: ");
  2640.         parse(",");
  2641.         strcpy(report.lastname,  string);
  2642.         parse(" (");
  2643.         strcpy(report.firstname, string);
  2644.         parse(" ,phone ");
  2645.         strcpy(report.company,   string);
  2646.         parse(")\n# Path: ");
  2647.         strcpy(report.phone,     string);
  2648.         parse("\n# ReferID: ");
  2649.         strcpy(report.email,     string);
  2650.         parse("\n");
  2651.         strcpy(report.developer, string);
  2652.     }
  2653.  
  2654.     /* first name */
  2655.     setgadget(166, 22, 256, 12, "_First name:", NULL);
  2656.     ST1_FirstName = PrevGadPtr = (struct Gadget *) CreateGadget
  2657.     (   STRING_KIND,
  2658.     PrevGadPtr,
  2659.     &Gadget,
  2660.     GTST_String, &(report.firstname),
  2661.     GTST_MaxChars, MEDFIELD,
  2662.     GA_TabCycle, TRUE,
  2663.         GT_Underscore, '_',
  2664.     TAG_DONE
  2665.     );
  2666.  
  2667.     /* last name */
  2668.     setgadget(166, 34, 256, 12, "_Last name:", NULL);
  2669.     ST1_LastName = PrevGadPtr = (struct Gadget *) CreateGadget
  2670.     (   STRING_KIND,
  2671.     PrevGadPtr,
  2672.     &Gadget,
  2673.     GTST_String, &(report.lastname),
  2674.     GTST_MaxChars, MEDFIELD,
  2675.     GA_TabCycle, TRUE,
  2676.         GT_Underscore, '_',
  2677.     TAG_DONE
  2678.     );
  2679.  
  2680.     /* company name */
  2681.     setgadget(166, 46, 256, 12, "_Company:", NULL);
  2682.     ST1_Company = PrevGadPtr = (struct Gadget *) CreateGadget
  2683.     (   STRING_KIND,
  2684.     PrevGadPtr,
  2685.     &Gadget,
  2686.     GTST_String, &(report.company),
  2687.     GTST_MaxChars, MEDFIELD,
  2688.     GA_TabCycle, TRUE,
  2689.         GT_Underscore, '_',
  2690.     TAG_DONE
  2691.     );
  2692.  
  2693.     /* phone */
  2694.     setgadget(166, 58, 256, 12, "_Phone number:", NULL);
  2695.     ST1_Phone = PrevGadPtr = (struct Gadget *) CreateGadget
  2696.     (   STRING_KIND,
  2697.     PrevGadPtr,
  2698.     &Gadget,
  2699.     GTST_String, &(report.phone),
  2700.     GTST_MaxChars, MEDFIELD,
  2701.     GA_TabCycle, TRUE,
  2702.         GT_Underscore, '_',
  2703.     TAG_DONE
  2704.     );
  2705.  
  2706.     /* developer number */
  2707.     setgadget(166, 70, 256, 12, "_Developer number:", NULL);
  2708.     ST1_Developer = PrevGadPtr = (struct Gadget *) CreateGadget
  2709.     (   STRING_KIND,
  2710.     PrevGadPtr,
  2711.     &Gadget,
  2712.         GTST_String, &(report.developer),
  2713.         GTST_MaxChars, LONGFIELD,
  2714.     GA_TabCycle, TRUE,
  2715.         GT_Underscore, '_',
  2716.     TAG_DONE
  2717.     );
  2718.  
  2719.     /* email */
  2720.     setgadget(166, 82, 256, 12, "_EMail:", NULL);
  2721.     ST1_EMail = PrevGadPtr = (struct Gadget *) CreateGadget
  2722.     (    STRING_KIND,
  2723.     PrevGadPtr,
  2724.     &Gadget,
  2725.     GTST_String, &(report.email),
  2726.     GTST_MaxChars, MEDFIELD,
  2727.     GA_TabCycle, TRUE,
  2728.         GT_Underscore, '_',
  2729.     TAG_DONE
  2730.     );
  2731.  
  2732.     drawgadgets((UWORD) ~0);
  2733.     ActivateGadget(ST1_FirstName, MainWindowPtr, NULL);
  2734.     loop();
  2735.  
  2736.         /* write out S:Report.sender
  2737.         # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
  2738.         # Path: <email><LF>
  2739.         # ReferID: <developer><LF> */
  2740.  
  2741.         strcpy(report.refer, "# Refer: ");
  2742.         strcat
  2743.         (   report.refer,
  2744.             ((struct StringInfo *) ST1_LastName->SpecialInfo)->Buffer
  2745.         );
  2746.         strcat(report.refer, ",");
  2747.         strcat
  2748.         (   report.refer,
  2749.             ((struct StringInfo *) ST1_FirstName->SpecialInfo)->Buffer
  2750.         );
  2751.         strcat(report.refer, " (");
  2752.         strcat
  2753.         (   report.refer,
  2754.             ((struct StringInfo *) ST1_Company->SpecialInfo)->Buffer
  2755.         );
  2756.         strcat(report.refer, " ,phone ");
  2757.         strcat
  2758.         (   report.refer,
  2759.             ((struct StringInfo *) ST1_Phone->SpecialInfo)->Buffer
  2760.         );
  2761.         strcat(report.refer, ")\n");
  2762.  
  2763.         strcpy(report.path, "# Path: ");
  2764.         strcat
  2765.         (    report.path,
  2766.             ((struct StringInfo *) ST1_EMail->SpecialInfo)->Buffer
  2767.         );
  2768.         strcat(report.path, "\n");
  2769.  
  2770.         strcpy(report.referid, "# ReferID: ");
  2771.         strcat
  2772.         (   report.referid,
  2773.             ((struct StringInfo *) ST1_Developer->SpecialInfo)->Buffer
  2774.         );
  2775.         strcat(report.referid, "\n");
  2776.  
  2777.         strcpy(IOBuffer, report.refer);
  2778.         strcat(IOBuffer, report.path);
  2779.         strcat(IOBuffer, report.referid);
  2780.     
  2781.         writeout("S:Report.sender");
  2782.         closewindow();
  2783. }
  2784.  
  2785. MODULE void sender_loop(ULONG class, struct Gadget* addr, UWORD code, UWORD qual)
  2786.     {   if (class == IDCMP_VANILLAKEY)
  2787.         {   code = toupper(code);
  2788.             if (code == ESCAPE)
  2789.             {   if ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT))
  2790.                 {   cleanexit(EXIT_SUCCESS);
  2791.                 } elif (shared.function == 1)
  2792.                 {   page = 11;
  2793.                 } else
  2794.                 {   // assert(shared.function == 3);
  2795.                     page = 32;
  2796.             }   }
  2797.             elif (code == 'F')
  2798.             {   ActivateGadget(ST1_FirstName, MainWindowPtr, NULL);
  2799.             } elif (code == 'L')
  2800.             {   ActivateGadget(ST1_LastName,  MainWindowPtr, NULL);
  2801.             } elif (code == 'C')
  2802.             {   ActivateGadget(ST1_Company,   MainWindowPtr, NULL);
  2803.             } elif (code == 'D')
  2804.             {   ActivateGadget(ST1_Developer, MainWindowPtr, NULL);
  2805.             } elif (code == 'P')
  2806.             {   ActivateGadget(ST1_Phone,     MainWindowPtr, NULL);
  2807.             } elif (code == 'E')
  2808.             {   ActivateGadget(ST1_EMail,     MainWindowPtr, NULL);
  2809.     }   }   }
  2810.  
  2811. AGLOBAL void getversion(STRPTR filename, STRPTR output)
  2812. {   ULONG i;
  2813.     TEXT  commandstring[VLONGFIELD + 1];
  2814.  
  2815.     if (ram)
  2816.     {   strcpy(commandstring, "RAM:Version ");
  2817.     } else
  2818.     {   strcpy(commandstring, "Version ");
  2819.     }
  2820.     strcat(commandstring, filename);
  2821.     strcat(commandstring, " >T:ReportPlus.temp");
  2822.     if (!SystemTags(commandstring, SYS_Output, Open("NIL:", MODE_NEWFILE), TAG_DONE))
  2823.     {   readordie("T:ReportPlus.temp");
  2824.         for (i = 0; i <= VLONGFIELD; i++)
  2825.         {   if (IOBuffer[i] == LF)
  2826.             {   IOBuffer[i] = 0;
  2827.                 break;
  2828.         }   }
  2829.         strcpy(output, IOBuffer);
  2830.     } else
  2831.     {   strcpy(output, "?");
  2832. }   }
  2833.  
  2834. AGLOBAL void setbar(ULONG max)
  2835. {   // Ensure we do no more than BARUPDATES updates of the progress bar.
  2836.  
  2837.     increment = max / BARUPDATES;
  2838.     if (increment == 0)
  2839.     {   increment = 1;
  2840. }   }
  2841.  
  2842.